0

我得到了我的数据库列日志,数据,类型如何从现在开始获取日志,并区分月份 f.ex:行

logs = 'error...'
data = 2012-11-05 11:24:08
type = 1

....我想让他们在那个视图中

month     logs-count   type
January     100         1
January     100         2
February    160         1
February    120         2
 ....
4

3 回答 3

0

试试这个,如果这些列在同一个表中

select monthname(data) as month,count(logs)as logs-count,type from table
 group by month
于 2012-11-15T11:22:06.740 回答
0

对于 mysql:

select monthname(data) as month, count(*) as logs-count, type
  from table
  group by month, type

您需要按日期和类型分组才能每月获得多行。

于 2012-11-15T11:33:32.120 回答
0

试试这个:

select datename(month, data) as month count(logs)as logscount, type from table
于 2012-11-15T11:28:35.467 回答