I have a SQL query:
Select * from random_table where dt >= date('12/1/2022')
The problem with this is its giving me daily data. Can I adjust this code and add date_trunc
to aggregate by month, if so, how would i do that?
I haven’t tried anything yet as I am a noob when it comes to SQL
2
Answers
Maybe you can use
DATE_FORMAT
, and select your aggregation functionUsing
STR_TO_DATE(dt, '%m/%d/%Y')
to convert your string to date, andDATE_FORMAT
to compare with the month neededTo show month instead of day :
Demo here