oracle 按天group by
时间: 2023-08-22 18:06:59 浏览: 125
在Oracle中,可以使用to_char()函数来按天进行group by操作。通过将日期字段传递给to_char()函数,并使用'yyyymmdd'格式参数,可以将日期统一转换为年月日的方式输出。例如:
```sql
select to_char(created_time,'yyyymmdd') as day,count(mobile_no)
from table
where to_char(created_time,'yyyymmdd') >= '20181201'
group by to_char(created_time,'yyyymmdd')
order by min(created_time) asc
```
以上SQL查询将按照日期(天)对数据进行分组,并对每个日期的mobile_no进行计数。结果按照最早创建时间的升序排列。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [Oracle中group by用法](https://blog.csdn.net/weixin_33171271/article/details/116341130)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* *3* [Oracle中按天、自然周、月、季、年周期统计](https://blog.csdn.net/fwj_ntu/article/details/86677327)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文