Luis Cazares (7/26/2016)
Just a small correction to J Livingston's query to avoid scanning the whole table.
SELECT
Custmer,
location,
SUM(CASE WHEN [Date] >= @mth_st AND [Date] < @mth_nx THEN Bill_value ELSE 0 END) AS cur_mth,
SUM(Bill_value) AS ytd
FROM #yourtable
WHERE [Date] >= @yr_st AND [Date] < @yr_nx
GROUP BY Custmer, location
thanks Luis.....should have seen that one 🙂
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day