in

SDT Community Server

SDT Forums, Blogs, Photos server.

This Blog

Syndication

Coolboy

Browse by Tags

All Tags » oracle日期 (RSS)
  • 关于oracle查询日期横向显示的问题

    表结构: 人员编码 月份 工时 天数 001 1 12 5 001 2 20 6 001 3 18 8 002 1 12 5 002 2 15 6 002 3 18 7 如何通过sql语句查询出如下显示结果 人员编码 内容 1月 2月 3月 ......12月 001 工时 12 20 18 001 天数 5 6 8 002 工时 12 15 18 002 天数 5 6 7 select 人员编码, decode(rn, 1 , ' 工时 ' , 2 , ' 天数 ' ) 内容, sum (decode(月份, 1 ,decode(rn, 1 ,工时, 2 ,天数), 0 )) 1月, sum (decode(月份, 2 ,decode(rn, 1 ,工时, 2 ,天数), 0 )) 2月, sum (decode(月份, 3 ,decode(rn, 1 ,工时, 2 ,天数), 0 )) 3月, sum (decode(月份, 4 ,decode(rn, 1 ,工时, 2 ,天数), 0 )) 4月, sum (decode(月份, 5 ,decode...
Copyright SDT, 2006-2009. All rights reserved.