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 |
|
evanburen
Posting Yak Master
167 Posts |
Posted - 2005-07-14 : 21:56:20
|
| My table, Texeccompsummary, contains multiple TotalTargetComp values for each ExecutiveID. I want to insert just the maximum value for each ExecutiveID into another table, Texecomp. I tried this but it's not working out. Thanks.Insert into Texecomp (TotalTargetComp)VALUES (select max(TotalTargetComp) from Texeccompsummarywhere Texeccomp.ExecutiveID = Texeccompsummary.ExecutiveID) |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-07-14 : 22:09:53
|
| have you tried...Insert into Texecomp (TotalTargetComp)select total from (select max(s.TotalTargetComp) as 'total',c.executiveIDfrom Texeccompsummary s join texeccomp con c.ExecutiveID = s.ExecutiveIDgroup by c.executiveID) t--------------------keeping it simple... |
 |
|
|
|
|
|