question

cadalal avatar image
cadalal asked

last Month Closing Balance be this month Opening Balance

Hello Gurus, This is table Insert into BDM.SLS.Daily_Sales SELECT CAST(ENTDTE AS INT) AS Entry_Date, ISNULL(DIVIS, 'NONE') AS Division, SUM(SALES) AS Current_Month_Sales, Daily_Sales = case (substring(cast(ENTDTE AS VARCHAR(8)),7,2)) WHEN '01' THEN COALESCE(ROUND((sum(A.SALES)),-2),0) ELSE COALESCE(ROUND((select SUM(A.SALES) - SUM(B.SALES) FROM ODS.NPNDATA.GAPPW019 B WHERE A.DIVIS = B.DIVIS AND A.ENTDTE= B.ENTDTE +1 GROUP BY B.DIVIS, B.ENTDTE), -2), 0) END, Daily_Orders = case (substring(cast(ENTDTE AS VARCHAR(8)),7,2)) WHEN '01' THEN COALESCE (ROUND((SUM(A.SALES+A.CMOORD+A.PDOORD+A.SNBORD)),-2),0) ELSE COALESCE(ROUND((select SUM(A.SALES+A.CMOORD+A.PDOORD+A.SNBORD) - SUM(C.SALES+C.CMOORD+C.PDOORD+C.SNBORD) FROM ODS.NPNDATA.GAPPW019 C WHERE A.DIVIS = C.DIVIS AND A.ENTDTE= C.ENTDTE +1 GROUP BY C.DIVIS, C.ENTDTE), -1), 0) AS Daily_Orders, SUM(FUOORD) AS Future_Open_Ord, SUM(FUHORD) AS Future_Held_Ord, SUM(NMOORD) AS Next_Open_Ord, SUM(NMHORD) AS Next_Held_Ord, SUM(CMOORD) AS Current_Open_Ord, SUM(CMHORD) AS Current_Held_Ord, SUM(PDOORD) AS Past_Due_Open_Ord, SUM(PDHORD) AS Past_Due_Held_Ord, SUM(SNBORD) AS Shipped_Not_Billed, Here i need to add 2 more column which has OnHand and CarryFwd balances by division. so for the month of april i would dike to see the number for the date of 20140331 and the columns would be NMOORD and for CarryFwd i need to value for the date of 20140331 and column would be CMOORD Thanks
insert
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.