Posts
1150
Comments
891
Trackbacks
1
T-SQL: Query using max in a self-reference

Since I always forget how to do this:

delete [table name]
from [table name] as t1
inner join
(
select column1, max(column2) as datadate from [table name]
group by column1
) as t2 on
t1.column1 = t2.column1
where t1.datadate <= dateadd(yy, -1, t2.datadate)
posted on Thursday, August 10, 2006 12:15 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 3 and 3 and type the answer here: