프로그램을 만드는데 다음과 같이 union all로 한 다음, 스트링 그리드로
계산해서 뿌릴려고 합니다.
그런데.. 만일 이걸 전부 서브 쿼리로 엮은다면 어떤게
더 낫은 속도를 보일까요?
이건 또 다른 질문인데요. 쿼리 결과에 대한 속도측정은 불가능한가요?
아니면 툴이 있다던가..
좋은 답변 부탁드립니다.
select a.goods, a.spec, '0' as gubun, '0' as seq,
a.initial_count as acnt, (a.initial_count * a.buy_price) as aprice,
a.sell_price, b.sell_unit_price, a.buy_price, b.buy_unit_price, c.name
from (oagoods010 a left join (select goods,spec,sell_unit_price, buy_unit_price from venprice
where client = '0142'
and goods like '%%') b on a.goods = b.goods and a.spec = b.spec)
left join OAMAKER c on a.maker = c.code
union all
select b.goods, b.spec, a.gubun, '1' as seq,
sum(b.cnt) as acnt, sum(b.price) as aprice, 0, 0, 0, 0, d.name
from ((BUYM010 a inner join BUYD010 b on a.sell_no = b.sell_no)
left join OAGOODS010 c on b.goods = c.goods and b.spec = c.spec)
left join OAMAKER d on c.maker = d.code
where a.gubun between '0' and '5'
group by b.goods, b.spec, a.gubun, d.name
union all
select b.goods, b.spec, a.gubun, '2' as seq,
sum(b.cnt) as acnt, sum(b.price) as aprice, 0, 0, 0, 0, d.name
from ((SELLM010 a inner join SELLD010 b on a.sell_no = b.sell_no)
left join OAGOODS010 c on b.goods = c.goods and b.spec = c.spec)
left join OAMAKER d on c.maker = d.code
where a.gubun between '0' and '6'
group by b.goods, b.spec, a.gubun, d.name
order by a.goods, a.spec, seq, gubun
이걸 기준으로 쿼리를 수정하시면 될것 같네요.