Q&A

  • [질문]쿼리좀 봐주세요...
<!--CodeS-->
Select Cast(Sum(T.WMiNab) as numeric(18,4)) WMiNab, Cast(Sum(T.DMiNab) as numeric(18,4)) DMiNab,
       Cast(Sum(T.WMiMae) as numeric(18,4)) WMiMae, Cast(Sum(T.DMiMae) as numeric(18,4)) DMiMae,
       Cast(Sum(T.WMiSugum) as numeric(18,4)) WMiSugum, Cast(Sum(T.DMiSugum) as numeric(18,4)) DMiSugum,
       Cast(Sum(T.JanKum) as numeric(18,4)) JanKum,
       Cast(Sum(T.DMiSugum) as numeric(18,4))+Cast(Sum(T.JanKum) as numeric(18,4)) DMiSu
  From (
        Select Cast(Sum((A.Surang-A.Chgorang-A.Canrang)*(A.Kum/A.Surang)) as numeric(18,4)) WMiNab, Cast(Sum((A.Surang-A.Chgorang-A.Canrang)*A.Danga) as numeric(18,4)) DMiNab, 0 WMiMae , 0 DMiMae, 0 WMiSugum, 0 DMiSugum, 0 JanKum
          From Suju A, Goodhis B
         where A.Chcode = '8029'
           And A.Sujuil <= '20090225'
           And A.Surang-A.Chgorang-A.Canrang > 0
           And A.Model = B.Model
           And A.Rev = B.Rev
           And A.ChCode = B.Chcode
        UNION
        Select 0 WMiNab, 0 DMiNab, Cast(Sum((A.Surang-A.Maerang)*(A.Kum/A.Surang)) as numeric(18,4)) WMiMae, Cast(Sum((A.Surang-A.Maerang)*A.Danga) as numeric(18,4)) DMiMae, 0 WMiSugum, 0 DMiSugum, 0 JanKum
          From GChgoT A
         where A.Chcode = '8029'
           And A.GChgoil <= '20090225'
           And A.Surang-A.Maerang > 0
        UNION
        Select 0 WMiNab, 0 DMiNab, 0 WMiMae, 0 DMiMae, Cast(Sum(M.TaxKum-(M.Ipgum-M.BilKum)) as numeric(18,4)) WMiSugum, Cast(Sum(M.DTaxKum-(M.Ipgum-M.BilKum)) as numeric(18,4)) DMiSugum, 0 JanKum
          From (
                Select Cast(Sum(A.IpgumMoney) as numeric(18,4)) Ipgum, 0 BilKum, 0 TaxKum, 0 DTaxKum
                  From IpgumH A
                 where A.Chcode = '8029'
                   And A.Ipgumil >= '20090101'
                   And A.Ipgumil <= '20091231'
                UNION
                Select 0 Ipgum, Cast(Sum(A.BillKum) as numeric(18,4)) BilKum, 0 TaxKum, 0 DTaxKum
                  From IpgumT A, IpgumH B
                 where B.Chcode = '8029'
                   And A.Mangiil > '20090225'
                   And A.Ipgumil = B.Ipgumil
                   And A.IpgumNo = B.IpgumNo
                UNION
                Select 0 Ipgum, 0 BilKum, Cast(Sum(A.TTAxKum) as numeric(18,4)) TaxKum, Cast(Sum(A.MaechD) as numeric(18,4)) DTaxKum
                  From TaxH A
                 where A.TaxChco = '8029'
                   And A.Taxil >= '20090101'
                   And A.Taxil <= '20091231'
                ) M
        UNION
        Select 0 WMiNab, 0 DMiNab, 0 WMiMae, 0 DMiMae, 0 WMiSugum, 0 DMiSugum, Cast(Sum(A.JanMoney) as numeric(18,4)) JanKum
          From ChStock A
         where A.Chcode = '8029'
           And A.YYYY = '2009'
        ) T

<!--CodeE-->

사용 환경

MSSQL 2000
델파이 6

위 쿼리는 한 업체의 미수금을 찾기 위한 쿼리인데요...
돌리면 결과 같이..

Select 순서대로...

9713536.0000        5415.0000        1327282.0000        739.9200        5216655.2820        -11800.9780        11800.9780        .0000

이렇게 나옵니다..

맨 마지막에 .0000 이라고 나오는 부분이 표시 되는 건데...
제가 돌리면 별 문제 없습니다.
근데 사용자 컴에서 돌리면 이게  -1.0000 이 나오네요..
같은 프로그램 쓰고 같은 DB를 쓰는데...

다만 전 소스로 실행 해서 보는 거고... 사용자는 제가 컴파일한 실행 파일을 돌리는 것 뿐인데..

차이가 나네요.. 이경우 어떻게 해야 할까요?

CAST( ) 이 함수는 않되서 일부러 써본겁니다.. 쩝...
계산용 필드라 전부 float 잡혀 있고요...
1  COMMENTS
  • Profile
    블랙레인 2009.02.27 23:03
    Cast(Sum(T.DMiSugum) as numeric(18,4))+Cast(Sum(T.JanKum) as numeric(18,4)) DMiSu 에서
    데이타값 확인 하시구요
    TRUNC 써보세요