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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Insert Statement

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 Texeccompsummary
where 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.executiveID
from Texeccompsummary s join texeccomp c
on c.ExecutiveID = s.ExecutiveID
group by c.executiveID) t




--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -