oracle存储过程,查询每个月的记录量

「已注销」 2019-08-16 10:12:22
oracle存储过程,查询每个月的记录量:如果当月没有则当月为0,返回是12个月的数据list,

大佬们,有没有会写的?

我之前用的mysql

select(
(select count(0) from xxxx ....) as "1月",
(select count(0) from xxxx ....) as "2月",
(select count(0) from xxxx ....) as "3月",
。。。
)

但是oracle中不能这样写,求大佬,急求

----------------------------

找到一个很简单的方法,但是没有数据的月份就没有月份和数据

select to_char(created_time,'MM') mon,count(*) num from mp_component_info t
where to_char(created_time,'yyyy')='2018'
group by to_char(created_time,'MM')
order by mon

求大佬。。。。。。
...全文
142 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
nayi_224 2019-08-16
  • 打赏
  • 举报
回复
select level from dual connect by level <= 12 外链接

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧