I am new to SQL.
in my query, I need max closeprice(column-name) with date (column-name). every month of that year.
I created this query:
Select max(close), date from commodity where commodity ='rice' and location= 'pune' year(date) ='2022' group by month(date) order by month(date) desc;
in this query, I got a max close price but I am not getting the actual max closeprice date. I am getting a max date with a max close price.
example
I want this: Actual max close price with that date and max close price
date close
2022-10-15 5600
2022-09-11 6200
I am getting is: max date and max close pice
date close
2022-10-31 5600
2022-09-30 6200
2
Answers
Try this:
A Simple
GROUP BY
on date column will help you to get such data