I got in my data base colums logs, data, type How to get logs from year from now with month distinction f.ex: row
logs = 'error...'
data = 2012-11-05 11:24:08
type = 1
.... And I want get them in that view
month logs-count type
January 100 1
January 100 2
February 160 1
February 120 2
....
try this,If these columns are in same table
select monthname(data) as month,count(logs)as logs-count,type from table
group by month
试试这个:
select datename(month, data) as month count(logs)as logscount, type from table
For mysql:
select monthname(data) as month, count(*) as logs-count, type
from table
group by month, type
You need to group by both date and type to get multiple rows per month.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.