当前位置: 首页 > news >正文

oracle 查询本年12月,ORACLE 写一条Sql语句查出年份,1月,2月,3月....12月的订单总数列表...

表结构:

CREATE TABLE [dbo].[Exam](

[S_date] [datetime] NOT NULL,

[Order_Id] [varchar](50) NOT NULL,

[Product_Id] [varchar](50) NOT NULL,

[Amt] [numeric](18, 0) NOT NULL

) ON [PRIMARY]

select y,sum(c1) as m1,sum(c2) as m2,sum(c3) as m3,sum(c4) as m4,sum(c5) as m5,sum(c6) as m6,

sum(c7) as m7,sum(c8) as m8,sum(c9) as m9,sum(c10) as m10,sum(c11) as m11,sum(c12) as m12

from

(

select

y,

case m when 1 then c else 0 end as c1,

case m when 2 then c else 0 end as c2,

case m when 3 then c else 0 end as c3,

case m when 4 then c else 0 end as c4,

case m when 5 then c else 0 end as c5,

case m when 6 then c else 0 end as c6,

case m when 7 then c else 0 end as c7,

case m when 8 then c else 0 end as c8,

case m when 9 then c else 0 end as c9,

case m when 10 then c else 0 end as c10,

case m when 11 then c else 0 end as c11,

case m when 12 then c else 0 end as c12

from

(

select y,m,count(s_date) as c from

(

select datepart(year,convert(DateTime,s_date)) as y,

datepart(month,convert(DateTime,s_date)) as m ,

s_date from exam

) as T1

group by T1.y,T1.m

)

as T2

) as T3

group by T3.y(这是sql server的)

相关文章:

  • sqlserver新建oracle发布是咋回事,SQLServer创建链接服务器对象链接oracle
  • linux桌面环境占用内存对比,最新精简型Linux桌面环境大比拼:LXDE Vs Xfce Vs MATE
  • dnw linux 内核,神器DNW2 FOR LINUX!
  • linux 单独装ftp服务,linux下安装FTP服务
  • linux日志服务重开,linux重新編譯內核
  • linux arm中断进程,ARM Linux对中断的处理
  • linux jvm自动退出,在Linux中启动Eclipse时出错:“ JVM已终止。退出代码= 13”
  • 远程监控linux的jboss,如何将JBoss做成Redhat Linux的系统服务
  • 火狐浏览器在linux下编译,linux下火狐浏览器插件开发.doc
  • linux vi编辑撤销,vi撤销命令(u和U),撤销上一次的操作
  • flask部署linux视频,基于python的web架构部署注意事项
  • Linux下载WordPress出现错误,解决wordpress发生意外错误,可能WordPress.org或服务器配置文件存在问题...
  • linux下github上传文件,linux下将本地文件上传到github中?
  • 具有二进制时钟的Linux,Unix Linux
  • c语言while语句里if,C语言中流程控制语句(if,switch,for,while,do-while,continue,break,return)...