--선생님(store - menu - review 조인)
select
smenu.sno, min(smenu.sname) ,min(smenu.regdate) ,min(viewcnt),
count(reviewno) , avg( nvl(score,0))
from (
select
store.sno , menu.mno, store.sname, store.regdate, store.viewcnt
from (
select *
from (
select /*+INDEX_DESC(tbl_store pk_store) */ rownum rn, sno, sname, regdate, viewcnt
from tbl_store
where sno > 0 and rownum <= 10
)
where rn > 0 ) store, tbl_menu menu
where store.sno = menu.sno(+) ) smenu, tbl_review review
where smenu.mno = review.mno(+)
group by smenu.sno;
--나(store와 review만 조인)
select store.sno, min(sname), count(reviewno), avg(score), max(reviewdate)
from(
select /*+INDEX_DESC(tbl_store pk_store) */ rownum rn, sno, sname
from tbl_store
where sno > 0 and rownum<=10
) store, tbl_review review
where store.sno = review.sno(+)
group by store.sno;
'코딩 > Oracle' 카테고리의 다른 글
JDBC설계 Step2 - (3) GenericDAO 만들기, Java Generic 예제 (0) | 2014.09.18 |
---|---|
JDBC설계 Step2 - (2) MenuVo 추가 (0) | 2014.09.18 |
JDBC설계 Step2 - (1) VOMaker 만들기 (0) | 2014.09.18 |
JDBC설계 Step1 - (4) org.soju.foodstore.test, java.sql.date와 Calendar 예제 (0) | 2014.09.18 |
JDBC설계 Step1 - (3) org.soju.foodstore.dao, Java enum 예제 (0) | 2014.09.17 |