Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tomsmith
Starting Member
2 Posts |
Posted - 2009-05-24 : 21:01:10
|
| Hi all,I'm new to SQL and would like to know how to do the following:Imagine I have a db which contains project files in various states (active, closed etc)I want to write a query that will list all the ones that are currently in a requested state and were made before July 2009From the client info in the db, I want to write a query that will extract the first name, last name, manager first and last name and logon ID.And lastly I want to return all the time records for a user (I have the user's first and last name in this case).If you need any more information let me know. Thanks.Tom |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-24 : 21:35:05
|
quote: I have a db which contains project files in various states (active, closed etc)I want to write a query that will list all the ones that are currently in a requested state and were made before July 2009
select *from projectswhere state = 'request'and request_date < '2009-07-01' quote: From the client info in the db, I want to write a query that will extract the first name, last name, manager first and last name and logon ID.
select c.first_name, c.last_name, m.first_name as Manager_First, m.last_name = Manager_Last_name, c.logon_idfrom client c inner join client m on c.manager_id = m.logon_id quote: I want to return all the time records for a user
select *from time_records t inner join client c on t.logon_id = c.logon_idwhere c.first_name = @first_nameand c.last_name = @last_name KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
tomsmith
Starting Member
2 Posts |
Posted - 2009-05-24 : 22:42:54
|
Hey thanks a lot for this. I'll give it a whirl and let you know.Thanks again.quote: Originally posted by khtan
quote: I have a db which contains project files in various states (active, closed etc)I want to write a query that will list all the ones that are currently in a requested state and were made before July 2009
select *from projectswhere state = 'request'and request_date < '2009-07-01' quote: From the client info in the db, I want to write a query that will extract the first name, last name, manager first and last name and logon ID.
select c.first_name, c.last_name, m.first_name as Manager_First, m.last_name = Manager_Last_name, c.logon_idfrom client c inner join client m on c.manager_id = m.logon_id quote: I want to return all the time records for a user
select *from time_records t inner join client c on t.logon_id = c.logon_idwhere c.first_name = @first_nameand c.last_name = @last_name KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|