I have a stock item table like this
I want to report on items that are not disconitnued or that have been discontinued this fiscal year only. I want to exclude any items discontinued previous fiscal year or before.
Disconitnued = 'Y'
Not discontinued = NULL
What is the best sql for that. I was thinking of somethig like this
select stock_code from stock_item where discontinued IS NULL OR (discontinued='Y' and date_discontinued >= '01-OCT-'||to_char(to_char(trunc(sysdate('YYYY'))-1)
since there is no function that subtracts 3 months from 1st day of year.
ADD_MONTHS only adds months.