다음의 코드를<!--CodeS-->
SQL.Text := 'select sum(PLH09) as SUM_M, Count(*) as CNT_M from PLH ' +
'where PLH03 = "M" and PLH11 = " "';
close;
open;
SUM_M := FindField('SUM_M').AsInteger;
CNT_M := FindField('CNT_M').AsInteger;
SQL.Text := 'select sum(PLH09) as SUM_K, Count(*) as CNT_K from PLH ' +
'where PLH03 = "K" and PLH11 = " "';
close;
open;
SUM_K := FindField('SUM_K').AsInteger;
CNT_K := FindField('CNT_K').AsInteger;
SQL.Text := 'select sum(PLH09) as SUM_C, Count(*) as CNT_C from PLH ' +
'where Not (PLH03 = "K" or PLH03 = "M") and PLH11 = " "';
close;
open;
SUM_C := FindField('SUM_C').AsInteger;
CNT_C := FindField('CNT_C').AsInteger;<!--CodeE-->
중첩 Select로 한줄로 할수 있는 방법은 없는지요?
select sum(PLH09) as SUM_M, Count(*) as CNT_M from PLH where PLH03 = "M" and PLH11 = " ") a,
(select sum(PLH09) as SUM_K, Count(*) as CNT_K from PLH where PLH03 = "K" and PLH11 = " ") b,
(select sum(PLH09) as SUM_C, Count(*) as CNT_C from PLH where Not (PLH03 = "K" or PLH03 = "M") and PLH11 = " ") c
위와 같이 서브 쿼리로 해주세요 그래야 속도도 많이 빠르죠... DB연결 끊기 다시 연결이런식으로 하면
속도 문제나 메모리 문제가 있어서 느려집니다.