【发布时间】:2015-02-01 20:23:39
【问题描述】:
我有一个包含日期时间、类型、度量的事务表。我想产生日期,计数,计数,类型=12,measure>20。
不知道该怎么做。
要知道日期,数,输入我会写 select date(datetime), count from table where type=12 group by date(datetime)
只是不确定如何添加第 3 列(按度量计数>20)。
我曾想过尝试左自连接或相关子查询。
感谢任何建议。
表名称警报
Col1 Alert_time(日期时间)
第 2 列 Alert_type(整数)
Col 3 度量(整数)
样本数据
2015/01/20 9:00|12|10
2015/01/20 8:00|12|30
2015/01/20 7:00|12|40
2015/01/21 5:00|13|30
2015/01/21 8:00|12|10
期望的输出
2015/01/20|3|2
2015/01/21|1|0
【问题讨论】:
-
请提供您的表结构和一些示例数据。