We help IT Professionals succeed at work.
Get Started


Last Modified: 2021-04-21
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

Watch Question
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
This problem has been solved!
Unlock 1 Answer and 26 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE