Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.80 KB | None | 0 0
  1. SELECT  wga.CalendarID, wga.Bookyear, wga.Period, sl.ID AS StructureLineID, sl.ParentStructureLineID, sl.OperatorPrimary, SUM(wga.AmountSigned * sla.Operator) AS Amount
  2. FROM    StructureLines sl
  3.         INNER JOIN StructureLineAccounts sla  ON (sla.StructureLineID = sl.ID)
  4.         INNER JOIN ( SELECT wga.AccountNumber, wga.Bookyear, wga.Period, wga.CalendarID, SUM(wga.AmountSigned) AS AmountSigned FROM `CA8658BE_13E7_4E60_8D87_89205836E064`.WemsyGeneralAccounting wga WHERE wga.CalendarCode <= '99-99' AND wga.LanguageID = 1 AND IsSimulation ='N' GROUP BY wga.AccountNumber,wga.Bookyear) AS wga ON (RPAD(wga.AccountNumber,8,'0') BETWEEN RPAD(sla.AccountStartGUI,8,'0') AND RPAD(sla.AccountEndGUI,8,'9'))
  5. WHERE   sl.StructureID = '1' AND wga.Bookyear = 5 AND StructureLineID = 212 AND wga.Period = 2
  6. GROUP BY sl.ID, wga.CalendarID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement