select ee1.start_day, ee1.ev_ym, ee1.ev_seq from ev001 ee1
inner join ev101 ee2 on ee1.ev_ym = ee2.ev_ym and ee1.ev_seq = ee2.ev_seq
where ee1.ev_can_cd is null
and ee1.good_type_cd = 'P'
and ee1.area_cd = 'CH'
and ee1.good_yy = '2006'
and ee1.good_seq = 96
and left(ee1.start_day,4) >= left(getdate(),4)
and start_day >= convert(varchar(10),getdate(),112)
order by ee1.start_day asc, ee2.adult_price asc
결과값
start_day | ev_ym | ev_seq
20070601 070601 84
20070601 070601 568
20070601 070601 55
20070601 070601 59
20070602 070602 73
20070602 070602 37
20070602 070602 42
20070602 070602 36
20070603 070603 27
20070603 070603 28
20070603 070603 60
20070603 070603 436
20070604 070604 60
20070604 070604 361
20070604 070604 27
20070604 070604 32
20070604 070604 26
...........................
...........................
원하는 결과값
20070601 070601 84
20070602 070602 73
20070603 070603 27
20070604 070604 60
설명
start_day 순으로 정렬한 후 adult_price 순으로 이차 정렬하고 start_day 중복을 제거한 각각의 start_day 의 맨위의 값을 가져 오고 싶습니다.
어떻게 하면 좋을까요? 원하는 결과값 처럼요~~ 도와주세요~~
|