darrennelson
asked on
SQL Sum
select I.InventoryID,
SUM(CASE WHEN
((getdate()+7) between D.BeginDate and D.EndDate)
THEN ROUND (I.Qty,0,0) ELSE 0 END) as 'Column1'
SUM(CASE WHEN
((getdate()+14) between D.BeginDate and D.EndDate)
THEN ROUND (I.Qty,0,0) ELSE 0 END) as 'Column2'
From Inventory I
INNER JOIN Date D
WHERE D.DateID=I.DateID
GROUP BY I.InventoryID
I need to create a view using the select above. Can I aggregate the results of Column1 and Column2 into a Column3 without using a temp table or variable? I also don't want to display Col1 or Col2.
The results of the above query look like this:
InventoryID Column1 Column2
1 6 7
I need the query to result in:
InventoryID Column3
1 13
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER