Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.
SELECT
SUM(T.SalesBal7) As July_2008,
SUM(T.SalesBal8) As Aug_2008,
SUM(T.SalesBal9) As Sept_2008,
SUM(T.SalesBal10) As Oct_2008,
SUM(T.SalesBal11) As Nov_2008,
SUM(T.SalesBal12) As Dec_2008
FROM arcpsale T
Left Outer Join arcusts T1 On T.CustID = T1.CustID
WHERE T1.CustAcct ='MAINE130^'
and T.FiscalYear =2008
SELECT
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal7 else 0 END) As July_2008,
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal8 else 0 END) As Aug_2008,
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal9 else 0 END) As Sept_2008,
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal10 else 0 END) As Oct_2008,
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal11 else 0 END) As Nov_2008,
SUM(CASE WHEN T.FiscalYear = 2008 then T.SalesBal12 else 0 END) As Dec_2008,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal1 else 0 END) As Jan_2009,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal2 else 0 END) As Feb_2009,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal3 else 0 END) As Mar_2009,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal4 else 0 END) As Apr_2009,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal5 else 0 END) As May_2009,
SUM(CASE WHEN T.FiscalYear = 2009 then T.SalesBal6 else 0 END) As Jun_2009
FROM arcpsale T
Left Outer Join arcusts T1 On T.CustID = T1.CustID
WHERE T1.CustAcct ='MAINE130^'
and T.FiscalYear BETWEEN 2008 AND 2009
SELECT
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal7 else 0 END) As July_2008,
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal8 else 0 END) As Aug_2008,
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal9 else 0 END) As Sept_2008,
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal10 else 0 END) As Oct_2008,
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal11 else 0 END) As Nov_2008,
SUM(CASE T.FiscalYear WHEN 2008 then T.SalesBal12 else 0 END) As Dec_2008,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal1 else 0 END) As Jan_2009,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal2 else 0 END) As Feb_2009,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal3 else 0 END) As Mar_2009,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal4 else 0 END) As Apr_2009,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal5 else 0 END) As May_2009,
SUM(CASE T.FiscalYear WHEN 2009 then T.SalesBal6 else 0 END) As Jun_2009
FROM arcpsale T
Left Outer Join arcusts T1 On T.CustID = T1.CustID
WHERE T1.CustAcct ='MAINE130^'
and T.FiscalYear BETWEEN 2008 AND 2009
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Alter an update query which rounds | 7 | 33 | |
SQL NULL vs Blank | 26 | 35 | |
Select only the top record in a left join | 13 | 34 | |
Separate 2 comma delimited columns into separate rows | 2 | 28 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
13 Experts available now in Live!