troubleshooting Question


Avatar of emi_sastra
emi_sastra asked on
Microsoft SQL Server 2005SQL
26 Comments1 Solution246 ViewsLast Modified:
Hi All,

I have query below and it does not work.

What's wrong with my code ?

Thank you.
SELECT A.EmpCode, SUM(A.QtyLsn) + CAST(SUM(A.QtyPcs) / 12 AS INTEGER) AS QtyLsn, SUM(CAST(A.QtyPcs % 12 AS INTEGER)) AS QtyPcs, SUM(B.Biaya1 * SUM(QtyLsn + CAST(QtyPcs / 12 AS INTEGER))) AS NilaiPekerjaanPerLsn, SUM(B.Biaya * CAST(QtyPcs % 12 AS INTEGER)) AS NilaiPekerjaanPerPcs  FROM  ( SELECT B.EmpCode , B.BarangCode , B.PekerjaanCode , SUM(B.QtyLsn) AS QtyLsn, SUM(B.QtyPcs) AS QtyPcs FROM THTRSSTOK2011 AS A LEFT JOIN TDTRSSTOK2011 AS B ON A.NoTransaksi = B.NoTransaksi WHERE TipeTransaksi = 'PRD' AND  CONVERT(Char(8), TglTransaksi, 112) BETWEEN '20110502' AND '20110515' GROUP BY B.EmpCode, B.BarangCode, B.PekerjaanCode  ) A  LEFT JOIN TDHPPPRODUK AS B ON A.BarangCode = B.ProdukCode AND A.PekerjaanCode = B.PekerjaanCode GROUP BY A.EmpCode

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 26 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 26 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros