쿼리;;

카테고리 없음 2011. 5. 13. 10:12
a테이블에
no, lv
1, 1
1, 2
1, 3
2, 1
2, 2
2, 3
3, 1
3, 2
3, 3

b테이블에
1, 1
2, 2
가 있으면

가져오고 싶은건
1, 2
2, 3
3, 1 

select no, min(a_lv) lv
from (
    select x.no, x.lv a_lv, nvl((select max(lv) from b where no = x.no), 0) b_lv
    from a x
)
where a_lv > b_lv
group by no
order by no
Posted by [czar]
,