Home > database > Mysql query a month count data every day
Mysql query a month count data every day
Time:10-19
Every day I want to check a month amount of alarm GROUP, GROUP BY groups, query before some year every month when I use the count (case when * * * *), but also to write 12 count (case when * * * *), query and month when every day is too much trouble, in this way have what method can be convenient?
CodePudding user response:
Data every day in a row, with the case before the method; If the daily data of each line, direct group, like this: Select groups, date_format (col_date, '% d'), sum (if (col_alert, null, 0, 1)) The from tab_name Where date_format (col_date, '% Y - % m)=' 2020-01 ' Group by groups, date_format (col_date, '% d');