PostgreSQL 实现按月按年,按日统计 分组统计
来源:互联网 发布:excel输入数据 编辑:程序博客网 时间:2024/05/22 13:04
参考博客园的文章,暂时在这里整理一下,后期再做补充。
--按年分组查看
select to_char(time_field, 'YYYY') as d , count(id) as total_count,sum (count_field) as total_amount from table_namewhere time_field between start_time and end_time group by d
--按月分组查看
select to_char(time_field, 'YYYY-MM') as d , count(id) as total_count,sum (count_field) as total_amount from table_name
where time_field between start_time and end_time group by d
--按天分组查看
select to_char(time_field, 'YYYY-MM-DD') as d , count(id) as total_count,sum (count_field) as total_amount from table_name
where time_field between start_time and end_time group by d
--按小时分组查看
select to_char(time_field, 'YYYY-MM-DD HH24 ' ) as d , count(id) as total_count,sum (count_field) as total_amount from table_name
where time_field between start_time and end_time group by d order by d
--按秒分组查看
select to_char(time_field, 'YYYY-MM-DD HH24:MI:SS ' ) as d , count(id) as total_countl,sum (count_field) as total_amount from table_name
where time_field between start_time and end_time group by d
阅读全文
0 0
- PostgreSQL 实现按月按年,按日统计 分组统计
- 按月分组统计
- SQL实现分组统计查询(按月、小时分组)
- SQL实现分组统计查询(按月、小时分组)
- UNIX时间戳 按月分组 按年月分组 按日分组 mysql语句
- 实现mysql按月统计
- mssql 按月统计,按日统计,按周统计,按季度统计
- 按年、按月、按周、按日进行统计分析
- sql语句分别按日,按周,按月,按季统计金额
- sql语句分别按日,按周,按月,按季统计金额
- Mysql按日、周、月进行分组统计
- MySQL统计函数记录——按月、按季度、按日、时间段统计
- oracle日期格式转换及日期截取,按月统计,按日统计
- Mysql 根据时间戳按年月日分组统计
- Mysql 根据时间戳按年月日分组统计
- Mysql 根据时间戳按年月日分组统计
- Mysql 根据时间戳按年月日分组统计
- Mysql 根据时间戳按年月日分组统计
- 01小项目
- live555 两个循环
- oracle新建用户相关操作
- 线性表的链式存储实现c++
- 根号n段合并排序算法的实现
- PostgreSQL 实现按月按年,按日统计 分组统计
- 页面之间的数据传递
- iOS设备中垂直同步开启后的帧率计数
- Next Permutation-leetcode下一个排列组合
- 图论-C语言-foundation(2)
- spring-jdbc常用sql语句
- 用vue-cli 自动构建的目录里面 (环境变量及其基本变量的配置)
- 欢迎使用CSDN-markdown编辑器
- PAT1003. Emergency (25)