반응형
출처 : http://blog.empas.com/hanidrap/22034991
if object_id ('tblx','u') is not null
drop table tblx
go
create table tblx
(idx int identity(1,1)
,cola char(3)
,colb smalldatetime
)
go
insert into tblx values ('aaa','2006-06-06')
insert into tblx values ('bbb','2006-06-05')
insert into tblx values ('aaa','2006-06-05')
insert into tblx values ('bbb','2006-06-04')
insert into tblx values ('ccc','2006-06-04')
insert into tblx values ('aaa','2006-06-04')
insert into tblx values ('ddd','2006-06-03')
insert into tblx values ('ddd','2006-06-03')
SELECT
*
FROM
TBLX V
WHERE IDX = (SELECT MIN(IDX) FROM TBLX WHERE V.COLA = COLA)
ORDER BY COLB DESC
[출처] 중복제거해서 가져오기|작성자 진카자마
반응형