I am trying to get counts for last 30 days with the following query -
SELECT date_occured, COUNT(*) FROM problem
WHERE date_occured >= (CURRENT_DATE - 30)
GRO
Here is the index friendly approach.
you don't need to use functions on columns if you use Oracle's Native MONTHS_BETWEEN function.
It returns difference in number of months. Days are also given as difference but on the precision side that is why I preferred to use BETWEEN clause
WHERE MONTHS_BETWEEN(date_occured, CURRENT_DATE - 30) BETWEEN 0 AND 1