mraetrudeaujr
Technical User
I have an SQL statement that I use to populate/build a report and it works beautifully --- however...I forgot to give the user the ability to use any date range that they want and put this on the report also. Here is the SQL statement;
I was thinking that maybe the 'Between' operator would go at the top and the 'And' operator would go in the middle. I have done this many times with a Select query in the Query design view, but not in SQL. I am trying to make to transition to using SQL exclusively because of what I have seen that it can do. Much more logical to look at, and understand. Thanks in advance
Code:
SELECT [STATION],
Sum(IIf([DISPOSITION]=1,1,0)) AS [VOLUNTARY RETURN],
Sum(IIf([DISPOSITION]=2,1,0)) AS [WA/NTA],
Sum(IIf([DISPOSITION]=3,1,0)) AS [TURNED OVER TO OTHER AGENCY]
FROM tbl_reinstatement
WHERE STATION Is Not Null
GROUP BY [STATION]
UNION ALL SELECT "Total",
Sum(IIf([DISPOSITION]=1,1,0)),
Sum(IIf([DISPOSITION]=2,1,0)),
Sum(IIf([DISPOSITION]=3,1,0))
FROM tbl_reinstatement
WHERE STATION Is Not Null;
I was thinking that maybe the 'Between' operator would go at the top and the 'And' operator would go in the middle. I have done this many times with a Select query in the Query design view, but not in SQL. I am trying to make to transition to using SQL exclusively because of what I have seen that it can do. Much more logical to look at, and understand. Thanks in advance