i have a report which i’m doing for work which i need some help with. The below query i shows what i’ve done so far, what i need now is to be able to get the info for each student that dropped on a day to day basis rather than give me a total at once, in other words take start one for example which is between 04-23 and 05-23 rather than getting the total at once i want it to provide results for each day at the time meaning today the results will show from 04-23 to 04-26 and tomorrow it updates to show results from 04-23 to 04-27 and so on and so forth. I would greatly appreciate if someone could please help. Thanks wise ones
SELECT
COUNT (dbo.cst_AdCancelsQE_vw.priorqecounter) AS 'Prior to QE',
COUNT (dbo.cst_AdCancelsQE_vw.duringqecounter) AS 'During QE',
COUNT (dbo.cst_AdCancelsQE_vw.afterqecounter) AS 'After QE',
dbo.cst_AdCancelsQE_vw.Division,
dbo.cst_AdCancelsQE_vw.Campus,
LEFT(CONVERT (VARCHAR,dbo.cst_AdCancelsQE_vw.Startdate , 101), 10)AS 'Start Date'
FROM dbo.cst_AdCancelsQE_vw
--JOIN dbo.cst_AdStatusChanges_vw
--ON dbo.cst_AdCancelsQE_vw.NewStatDescrip = dbo.cst_AdStatusChanges_vw.NewStatDescrip
WHERE StartDate IN ('2012-04-23', '2012-05-07', '2012-03-12')
GROUP BY dbo.cst_AdCancelsQE_vw.division, dbo.cst_AdCancelsQE_vw.campus, dbo.cst_AdCancelsQE_vw.startdate
ORDER BY dbo.cst_AdCancelsQE_vw.division, dbo.cst_AdCancelsQE_vw.campus ASC
Instead of
WHEREtoday-yesterday-and the day before, you should say Between TODAY and TODAY – 3 days.There you have an example for the last 3 days. You should be able to make it fix your requirements.
This way you have a query that works on a daily basis, if you run it today you get results for last 3 days, when it’s tomorrow and you run it again, you’ll get a new set of results.