Several variants:
Here you can use the to_char function. Check this link for an explanation: http://www.techonthenet.com/oracle/functions/to_char.php
You can also try using the case statement
select case when date >='10-OCT-2007' and date <'10-OCT-2008' then 'FY08' when date >='10-OCT-2008' and date <'10-OCT-2009' then 'FY09' else 'Other' end as fiscal_year, count(*) from mytable group by case when date >='10-OCT-2007' and date <'10-OCT-2008' then 'FY08' when date >='10-OCT-2008' and date <'10-OCT-2009' then 'FY09' else 'Other' end
Ultimately, if you are creating table privileges, you might want to create a date lookup table. Find the "date dimension" in the data warehouse guides.
For example:
Your table will have date, date_desc, financial_year, etc.
then you can just join the group for the fiscal year or whatever you want.
mcpeterson
source share