select name,
SUM(case ab when '1' then 1 else 0 end)as a,
SUM(case ab when '2' then 1 else 0 end)as b,
SUM(case ab when '3' then 1 else 0 end)as c,
SUM(case ab when '4' then 1 else 0 end)as d,
SUM(case ab when '5' then 1 else 0 end)as e,
SUM(case ab when '6' then 1 else 0 end)as f,
SUM(case ab when '7' then 1 else 0 end)as g,
SUM(case ab when '8' then 1 else 0 end)as h,
SUM(case ab when '9' then 1 else 0 end)as i,
SUM(case ab when '20' then 1 else 0 end)as z,
SUM(case ab when '21' then 1 else 0 end)as k,
SUM(case ab when '22' then 1 else 0 end)as l,
SUM(case ab when '23' then 1 else 0 end)as m,
SUM(case ab when '24' then 1 else 0 end)as n,
SUM(case ab when '30' then 1 else 0 end)as z,
SUM(case ab when '31' then 1 else 0 end)as k,
SUM(case ab when '32' then 1 else 0 end)as l,
SUM(case ab when '33' then 1 else 0 end)as m,
SUM(case ab when '34' then 1 else 0 end)as n,
SUM(case ab when '1' then 1 else 0 end)as a,
SUM(case ab when '2' then 1 else 0 end)as b,
SUM(case ab when '3' then 1 else 0 end)as c,
SUM(case ab when '4' then 1 else 0 end)as d,
SUM(case ab when '5' then 1 else 0 end)as e,
SUM(case ab when '6' then 1 else 0 end)as f,
SUM(case ab when '7' then 1 else 0 end)as g,
SUM(case ab when '8' then 1 else 0 end)as h,
SUM(case ab when '9' then 1 else 0 end)as i,
SUM(case ab when '20' then 1 else 0 end)as z,
SUM(case ab when '21' then 1 else 0 end)as k,
SUM(case ab when '22' then 1 else 0 end)as l,
SUM(case ab when '23' then 1 else 0 end)as m,
SUM(case ab when '24' then 1 else 0 end)as n,
SUM(case ab when '30' then 1 else 0 end)as z,
SUM(case ab when '31' then 1 else 0 end)as k,
SUM(case ab when '32' then 1 else 0 end)as l,
SUM(case ab when '33' then 1 else 0 end)as m,
SUM(case ab when '34' then 1 else 0 end)as n,
解决方案 »
- 不显示删除回复显示所有回复显示星级回复显示得分回复 帮帮小妹啊!我是新手刚刚开始学oracle!!我要用oracle为车牌识别系统建立一个数据库~~不知道怎么
- exp/imp问题
- 通过db-link调用的两个接口函数的操作是否一定属于同一个事务?急!跪谢!
- 关于项目中使用系统统一序列还是单表独立序列
- 疑问?oracle表空间的大小丢失!
- 高分求教关于ORACLE表字段输入规则的问题
- 请教一个sql语句
- 大侠们,谁能提供一些关于编写oracle语句的书呀???和oracle的经典书籍
- Oracle中怎么不能使用Default?怎么解决啊?
- 怎样取得距离现在最久的五条记录(分有时间字段pdate和无时间字段两种)
- 只读表空间为什么可以drop表?
- 报表中个一个字段显示两个字段
请帮忙简化
你的查询列表本来就需要这些列,没有必要简化。
SUM(decode ( ab ,'34' ,1 ,0 ))
如果说把case换成decode,也谈不上简化吧
他现在已经行列转换了,把列转成行A,B,C,D了.