emi_sastra
asked on
ADD PCS INTO DOZENS
Hi All,
I have data dozens and pcs.
I want to add those pcs >=12 into dozens, and remain pcs < 12.
Below is my code, but failed to achieve it.
SUM(QtyLsn) + FLOOR(CAST(SUM(QtyPcs)/12 AS MONEY)) AS QtyLsn
, SUM(QtyPcs) - FLOOR(CAST(SUM(QtyPcs)/12 AS MONEY)) AS QtyPcs
How could I do it ?
Thank you.
I have data dozens and pcs.
I want to add those pcs >=12 into dozens, and remain pcs < 12.
Below is my code, but failed to achieve it.
SUM(QtyLsn) + FLOOR(CAST(SUM(QtyPcs)/12 AS MONEY)) AS QtyLsn
, SUM(QtyPcs) - FLOOR(CAST(SUM(QtyPcs)/12 AS MONEY)) AS QtyPcs
How could I do it ?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I use :
SUM(QtyLsn) + CAST(SUM(QtyPcs)/12 AS INT) AS QtyLsn
, SUM(QtyPcs) % 12 AS QtyPcs
Thank you very much for your hep.