sql - 需要 SQL 查询以在 oracle 中打印从 2016 年 11 月到 2018 年 10 月的月份和年份记录数
问题描述
需要 SQL 查询来打印 Oracle 中从 2016 年 11 月到 2018 年 10 月的月和年记录计数。
例子
表 xyz:
Count(*)| Mon-YYYY|
234440 | Nov-2016|
234443 | DEC-2016|
234445 | JAN-2016|
234446 | FEB-2016|
;
;
;
;
234446 | OCT-2018|
解决方案
一般来说&简单地写(以斯科特的 EMP 表为例),就像
select
to_char(hiredate, 'yyyy.mm') year_month,
count(*)
from emp
where hiredate between date '2016-11-01' and date '2018-10-01'
group by to_char(hiredate, 'yyyy.mm')
order by to_char(hiredate, 'yyyy.mm');
推荐阅读
- html - 如何强制将 br 分隔的链接列表显示为项目符号列表?
- html - How can I display html image in a container the same way css displays background-image?
- python - 从页面获取脚本标签的内容并使用 python 将其保存为 javascript 文件格式
- keycloak - 使用 keycloak rest api 更新用户的问题
- android - 深度链接在 Chrome 移动浏览器中不起作用
- oracle - GRANT SELECT ON view TO user using script on SQL developer, 而不是 SELECT * FROM SQL Plus 中的那个视图
- java - Android:如何将 ImageView 保存到 SharedPreferences 以进行保存和检索?
- sql - 是否可以在 SUM 函数中使用 COALESCE 函数?
- arrays - 制作宾果游戏:如何检查数组中的元素是否重复并更改其值而不再次与其他元素重复
- excel - VBS 脚本无法将文件上传到共享点