`

列转行+合并一行

 
阅读更多
select t3.departmentname, wm_concat(t3.a), wm_concat(t3.b), wm_concat(t3.c)
from (select t1.departmentname,decode(t.ondutydate,'20120526080000',t.leadername) as a,
decode(t.ondutydate,'20120527080000',t.leadername) as b,
decode(t.ondutydate,'20120528080000',t.leadername) as c
  from ONDUTY_LEADERDUTY t,DEPARTMENT t1 where t1.departmentid=t.departmentid(+)
and  t.ondutydate>='20120526080000' and t.ondutydate<='20120528080000' and t1.fatherdepartmentid='1121040000000'
)t3 group by t3.departmentname
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics