table:
例:
year month errors2009 2 32009 5 2
想要的结果:
1.2009 1 0
2.2009 2 3
3.2009 3 0
4.2009 4 0
5.2009 5 2....
就是想没有的月份填充0
谢谢
例:
year month errors2009 2 32009 5 2
想要的结果:
1.2009 1 0
2.2009 2 3
3.2009 3 0
4.2009 4 0
5.2009 5 2....
就是想没有的月份填充0
谢谢
解决方案 »
- oracle 大数据查询优化的方案
- 抽出大量数据时如何逐条抽出每一条记录?
- 参数日期相减的问题
- 怎么转换oracle的日期格式?
- 我用sql*plus开发程序,创建表和创建相应的触发器都可以在sql*plus中编写代码吗?
- 在装Oracle的时候到自制数据库文件和创建并启动Oracle例程的时候过不去,是怎么回事?
- 哪里能下载到ORACLE9i的patch文件?(高分跪求!!!!!!)
- 求教高人:如何将VFP6.0中的表导入到Oracle8i中?急,在线等待
- ORACLE pl/sql 中没有没有办法知道执行的时间,I/O统计信息
- 关于日期型字段查询问题
- 查询视图无法使用索引
- 调试存储过程遇到数据库错误如何查看错误信息
union all select 2009,5,2 from dual)
select a.year,a.month,nvl(b.errors,0) from
(select a1.year,a2.month from
(select distinct year from tt)a1,
(select rownum month from dual connect by rownum<=12)a2)a,
tt b
where a.year=b.year(+) and a.month=b.month(+)
order by a.year,a.month
(
select 2009 year, 2 month, 3 errors from dual
union all
select 2009, 5, 2 from dual
)
select nvl(year,b.a),nvl(month,b.b),nvl(errors,0) from temp a,
(select to_char(sysdate,'yyyy') a,to_char(rownum,'00') b from dual connect by rownum<13)b
where b.a=a.year(+) and b.b=a.month(+)--result:2009 1 0
2009 2 3
2009 3 0
2009 4 0
2009 5 2
2009 6 0
2009 7 0
2009 8 0
2009 9 0
2009 10 0
2009 11 0
2009 12 0