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 |
|
plevine
Starting Member
2 Posts |
Posted - 2009-02-23 : 15:38:16
|
| Hi,Table Tasks This tabkle defines all the possible tasksID||||Name1|||||This2|||||That3|||||The Other4|||||Something else5|||||AnotherTable TaskHistory This table records only the active tasks associated with a job and the user completed.Job|||||Update|||||TaskID||||User||||Complete100|||||2/4/2009||||3||||||||bob|||||null100|||||2/4/2009||||4||||||||bob|||||null101|||||2/5/2009||||1||||||||joe|||||2/9/2009I am trying to write a query that would return all the tasks but would also indicate which specific tasks are associated with a transaction. For instance for transaction 101 I would likeTask|||||||TaskID|||||||complete1 |||||||1 |||||||2/9/20092 |||||||null |||||||null3 |||||||null |||||||null4 |||||||null |||||||null5 |||||||null |||||||nullIs this possible? The problem I have is when I add a WHERE statement to the left join. Then I no longer get a list of all the possible tasks.(I am doing it this way because the results are being bound to ASP NET datagrid) Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-02-23 : 15:42:15
|
LEFT JOIN Table2 AS t2 ON t2.Col = t1.Col AND t2.SomeCol = 'P' E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-23 : 15:43:23
|
| [code]Select T.ID,Z.TaskID,Z.Completefrom Tasks t Left outer join Taskhistory ZOn T.Id = Z.TaskID and Z.job = 101[/code] |
 |
|
|
plevine
Starting Member
2 Posts |
Posted - 2009-02-23 : 16:40:07
|
| Thank you for your timely and knowledgeable reply! |
 |
|
|
|
|
|