실행중 에러발생 a.compcode not found error 라는 에러를 발생시킵니다.
근데 문장2)를 쿼리어널리시스에서 하면 잘됨니다.
그러나 문장1)을 실행중에 코딩을 하여 돌리면 위에서 말한 에러가 발생합니다
정말 미치고 환장할 노릇입니다
테이블이 필드명도 존재를 하고 쿼리의 필드 에디터에는 아무것도 올라와 있지안아요
부탁드립니다
사용환경 WIN98, MSSQL7 DEL6을 사용합니다.
문장1) - a.compcode not found error 에러 발생
WITH QRYTaxMain do
BEGIN
CLOSE;
SQL.Clear;
SQL.Add('SELECT B.BONSACODE, B.BONSA, Count(BONSACODE) AS BONSACount,');
SQL.Add('Sum(CASE WHEN chkIO=''세입'' THEN 1 ELSE 0 END) AS Dcount,');
SQL.Add('Sum(CASE WHEN chkIO=''세추'' THEN 1 ELSE 0 END) AS RDcount,');
SQL.Add('Sum(CASE WHEN chkIO=''세출'' THEN 1 ELSE 0 END) AS Rcount,');
SQL.Add('Sum(CASE WHEN chkIO=''세환'' THEN 1 ELSE 0 END) AS RRcount,');
SQL.Add('Sum(CASE WHEN chkIO=''세입'' THEN Mflow ELSE 0 END) AS DMflow,');
SQL.Add('Sum(CASE WHEN chkIO=''세입'' THEN Mvat ELSE 0 END) AS DMvat,');
SQL.Add('Sum(CASE WHEN chkIO=''세입'' THEN Msum ELSE 0 END) AS DMsum,');
SQL.Add('Sum(CASE WHEN chkIO=''세추'' THEN Mflow ELSE 0 END) AS RDMflow,');
SQL.Add('Sum(CASE WHEN chkIO=''세추'' THEN Mvat ELSE 0 END) AS RDMvat,');
SQL.Add('Sum(CASE WHEN chkIO=''세추'' THEN Msum ELSE 0 END) AS RDMsum,');
SQL.Add('Sum(CASE WHEN chkIO=''세출'' THEN Mflow ELSE 0 END) AS RMflow,');
SQL.Add('Sum(CASE WHEN chkIO=''세출'' THEN Mvat ELSE 0 END) AS RMvat,');
SQL.Add('Sum(CASE WHEN chkIO=''세출'' THEN Msum ELSE 0 END) AS RMsum,');
SQL.Add('Sum(CASE WHEN chkIO=''세환'' THEN Mflow ELSE 0 END) AS RRMflow,');
SQL.Add('Sum(CASE WHEN chkIO=''세환'' THEN Mvat ELSE 0 END) AS RRMvat,');
SQL.Add('Sum(CASE WHEN chkIO=''세환'' THEN Msum ELSE 0 END) AS RRMsum');
SQL.Add('FROM TTAXMAIN A, TCODCOMP B');
SQL.Add('WHERE A.CompCode = B.COMPCODE AND A.COMPCODE Like ''%' + Edit1.Text + '%''');
SQL.Add('AND A.Drgst >= ''' + DateToStr(dtSdate.Date) + ''' AND A.Drgst <= ''' + DateToStr(dtEdate.Date) + '''');
SQL.Add('Group by B.BONSA, B.BONSACODE');
IF ComboBox1.ItemIndex = 0 THEN
SQL.Add('Order by B.BONSA')
else
SQL.Add('Order by B.BONSACODE');
ACTIVE := TRUE;
END;
문장2) - 잘 실행됨SELECT B.BONSACODE, B.BONSA, Count(BONSACODE) AS BONSACount,
Sum(CASE WHEN chkIO='세입' THEN 1 ELSE 0 END) AS Dcount,
Sum(CASE WHEN chkIO='세추' THEN 1 ELSE 0 END) AS RDcount,
Sum(CASE WHEN chkIO='세출' THEN 1 ELSE 0 END) AS Rcount,
Sum(CASE WHEN chkIO='세환' THEN 1 ELSE 0 END) AS RRcount,
Sum(CASE WHEN chkIO='세입' THEN Mflow ELSE 0 END) AS DMflow,
Sum(CASE WHEN chkIO='세입' THEN Mvat ELSE 0 END) AS DMvat,
Sum(CASE WHEN chkIO='세입' THEN Msum ELSE 0 END) AS DMsum,
Sum(CASE WHEN chkIO='세추' THEN Mflow ELSE 0 END) AS RDMflow,
Sum(CASE WHEN chkIO='세추' THEN Mvat ELSE 0 END) AS RDMvat,
Sum(CASE WHEN chkIO='세추' THEN Msum ELSE 0 END) AS RDMsum,
Sum(CASE WHEN chkIO='세출' THEN Mflow ELSE 0 END) AS RMflow,
Sum(CASE WHEN chkIO='세출' THEN Mvat ELSE 0 END) AS RMvat,
Sum(CASE WHEN chkIO='세출' THEN Msum ELSE 0 END) AS RMsum,
Sum(CASE WHEN chkIO='세환' THEN Mflow ELSE 0 END) AS RRMflow,
Sum(CASE WHEN chkIO='세환' THEN Mvat ELSE 0 END) AS RRMvat,
Sum(CASE WHEN chkIO='세환' THEN Msum ELSE 0 END) AS RRMsum
FROM TTAXMAIN A, TCODCOMP B WHERE A.CompCode = B.COMPCODE
Group by B.BONSA, B.BONSACODE
Order by B.BONSA