Maximum value populated in a date column for each of last 5 months

I have a column "business_date" of date datatype inside my table. Data is uploaded almost daily into that table.

I want to write a query to find the maximum value populated in this column for every month for the last 5 months.

How can I do this?
sunny82Asked:
Who is Participating?
 
gatorvipCommented:
I want to write a query to find the maximum value populated in this column

Do you mean the maximum value in business_date? That seems rather odd, but this should work:

select max(business_date), trunc(business_date, 'MM')
from <your_table>
where business_date >= add_months( trunc(business_date, 'MM') , -5)
group by trunc(business_date, 'MM')
0
 
sunny82Author Commented:
Great, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.