SQL Server 2000, SP4
I have one table that has entries based on a date. I am trying to get a sum of entries based on the last date within a month and only that date. Here is what I have so far.
The table has two runs of data for one month. One run on the 15th and one run on the 29th. I can get a sum for both dates however I would like to only see the sum for the run on the 29th on the month. The last run done during that specific month. Then do that for each month within the range (quarter, year, etc.).
What am I missing? Can anyone point me in the right direction?
zemp
I have one table that has entries based on a date. I am trying to get a sum of entries based on the last date within a month and only that date. Here is what I have so far.
Code:
SELECT TOP 100 PERCENT ClientNumber, SUM(CurrentLives) AS Lives, CurrentDate, CurrentMonth
FROM dbo.DrugLives
GROUP BY ClientNumber, CurrentDate, CurrentMonth
HAVING (ClientNumber = '0801')
ORDER BY CurrentDate DESC
What am I missing? Can anyone point me in the right direction?
zemp