제가 초보라.. 이렇게 일단 만들어는 봤는데...
아무리 봐도... 이건 아니다 싶어서...
좀더 나은 방법이 없을까 궁금해서... 부탁 드립니다......
select iotonm.ioto
, sdojcode1.codecnt, sdojcode2.codecnt, sdojcode3.codecnt,
sdojcode4.codecnt
, sdojcode5.codecnt, sdojcode6.codecnt, sdojcode7.codecnt,
sdijcode1.codecnt
, sdijcode2.codecnt, sdijcode3.codecnt, sdijcode4.codecnt,
sdijcode5.codecnt
, sdijcode6.codecnt, sdijcode7.codecnt
from (select ioto
from sdorejtt
where srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto
union
select ioto
from sdirejtt
where srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto) iotonm
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 1
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode1
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 2
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode2
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 3
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode3
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 4
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode4
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 5
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode5
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 6
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode6
, (select ioto, count(ioto) codecnt
from sdorejtt
where rejtcode = 7
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdojcode7
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 1
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode1
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 2
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode2
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 3
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode3
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 4
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode4
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 5
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode5
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 6
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode6
, (select ioto, count(ioto) codecnt
from sdirejtt
where rejtcode = 7
and srdate between to_date(20030301, 'YYYY-MM-DD') and
to_date(20040331, 'YYYY-MM-DD')
group by ioto)sdijcode7
where iotonm.ioto = sdojcode1.ioto(+)
and iotonm.ioto = sdojcode2.ioto(+)
and iotonm.ioto = sdojcode3.ioto(+)
and iotonm.ioto = sdojcode4.ioto(+)
and iotonm.ioto = sdojcode5.ioto(+)
and iotonm.ioto = sdojcode6.ioto(+)
and iotonm.ioto = sdojcode7.ioto(+)
and iotonm.ioto = sdijcode1.ioto(+)
and iotonm.ioto = sdijcode2.ioto(+)
and iotonm.ioto = sdijcode3.ioto(+)
and iotonm.ioto = sdijcode4.ioto(+)
and iotonm.ioto = sdijcode5.ioto(+)
and iotonm.ioto = sdijcode6.ioto(+)
and iotonm.ioto = sdijcode7.ioto(+)
;
|