I'm creating a query that gets the amount of retired people per fiscal year. Let's say I have this table:
table1
| FY | Reason for leave |
|2011-12| sick |
|2011-12| retired |
|2011-12| retire |
|2012-13| sick |
|2014-15| retired |
|2014-15| retired |
|2014-15| retired |
My Query is:
Select FY, Count(*) FROM table1 WHERE [Reason for leave] = "retired";
The problem is it won't return 2012-13 as one of the fiscal years, which makes sense, but I'd like for it to include all the years with either 0 or a blank as the count column
Thanks alot in advance!
FYto eitherint,char(4), orDate. Basically store the fiscal year, not the year range which adds no benefit. Usingintordate(set to month = 1, day = 1) will make it possible to constrain values, filter values, and also perform calculations. If you really must then usechar(4). What you have in there now makes it possible for an application error (or manual update) to enter an invalid value like2015-14and you won't know until you discover that a query result does not return what you were expecting.