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 |
|
basicconfiguration
Constraint Violating Yak Guru
358 Posts |
Posted - 2012-07-06 : 17:09:05
|
| declare @ad table (adcontrolid int)insert @ad select 1 union allselect 2 union allselect 3 union allselect 4declare @adevent table (adcontrolid int, moderationdate datetime)insert @adevent select 1, getdate() -1 union allselect 1, getdate() union allselect 2, '04-01-2012' union allselect 2, '03-01-2012'I like to get the latest moderation date. I dont wanna have 4 records result. I just want 2 records, like below.return:1, getdate()2, '04-01-2012' |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-07-06 : 17:11:23
|
| SELECT adcontrolid, MAX(moderationdate) FROM @adevent GROUP BY adcontrolid |
 |
|
|
basicconfiguration
Constraint Violating Yak Guru
358 Posts |
Posted - 2012-07-07 : 22:22:23
|
| That was fast. thank rob! |
 |
|
|
|
|
|