To display sum of qty based on current date and previous date

In the below query i am trying to get sum of qty based on current date and previous date.In my case it is not working it shows null but the values are present in the table.my expected result is

Quantity | Date
200      | 20-5-2015
15       | 19-5-2015

Select SUM(RecommentedQuantity) FROM IndentDetails ID
LEFT OUTER JOIN Indent I On I.IndentID=ID.IndentID
WHERE ID.CreatedOn =GETDATE()
UNION

Select SUM(RecommentedQuantity) FROM IndentDetails ID
LEFT OUTER JOIN Indent I On I.IndentID=ID.IndentID
WHERE ID.CreatedOn =       dateadd(d, datediff(d, 0, GETDATE())-1, 0) 


Source: sql

Leave a Reply