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 |
|
iancuct
Yak Posting Veteran
73 Posts |
Posted - 2002-10-09 : 10:50:13
|
| Hello sql gurusWeekEndingDate EarnedValue SubTaskNumber9/1/2002 $334.40 19/29/2002 $352.00 19/29/2002 $440.00 29/29/2002 $22.60 410/27/2002 $704.00 210/27/2002 $16.80 310/27/2002 $452.00 412/1/2002 $880.00 212/1/2002 $336.00 3I need to write a query that would append the max earned valuefor a given subtask to weekending dates where that subtask does notexist: Example10/27/2002 $352.00 112/1/2002 $452.00 4 |
|
|
iancuct
Yak Posting Veteran
73 Posts |
Posted - 2002-10-09 : 12:02:54
|
| sorry for the cross post, i had to refresh because the page wasn't displaying. |
 |
|
|
1fred
Posting Yak Master
158 Posts |
Posted - 2002-10-09 : 12:07:04
|
| This is working but you have do to it for each date, just put all your date in a temp table(id,date) and loop throughyour id and replace the date in my query with the variable.select b.earnedValue,b.subtaskNumber from table1,(select table1.weekendingDate,table1.earnedValue,table1.subtaskNumber from table1,(select SubtaskNumber,max(earnedValue) as earnedValue from table1group by SubtaskNumber) awhere a.SubtaskNumber = table1.SubtaskNumber and a.earnedvalue = table1.earnedValuegroup by table1.weekendingDate,table1.earnedValue,table1.subtaskNumber)bwhere table1.weekendingdate = '2002-12-01' and b.subtaskNumber not in(select subtaskNumber from table1 where table1.weekendingdate = '2002-12-01')group by b.earnedValue,b.subtaskNumber |
 |
|
|
|
|
|