【发布时间】:2014-01-07 21:14:47
【问题描述】:
我对 SQL 很陌生,我正在运行类似的东西来提取一些数据。但目前我一次运行一个语句并将它们复制到 excel 中。有没有办法将所有这些一起运行?每个语句的级别相同,但 count(ID) 会不同。也可能有些日子一个级别没有任何数据。
select
count(ID), level
from table1
where createat >= "2013-11-22 00:00:00" and createat <= "2013-11-22 23:59:59"
group by level;
select
count(ID), level
from table1
where createat >="2013-11-23 00:00:00" and createat <= "2013-11-23 23:59:59"
group by level;
select
count(ID), level
from table1
where createat >= "2013-11-24 00:00:00" and createat <= "2013-11-24 23:59:59"
group by level;
感谢您的帮助!我希望更多地了解如何编写这些。
【问题讨论】:
-
1) 提供您使用的数据库类型 2) 使用日期函数从日期列中提取月份中的哪一天,并使用它来简化您的查询和按天分组,如果这是什么你想要
标签: sql select count group-by sum