oracle里面的行转列的语句,高分请教!!!!

[复制链接]
查看11 | 回复1 | 2010-9-12 13:54:47 | 显示全部楼层 |阅读模式
我的表结构如下:
表名字叫table,一个名字,一个权限ID
name quanxianid
a
80
a
90
b
80
b
100
c
90
c
100
想转换成这样的:
name
80
90
100
a
true
true
F
b
true
F
true
c
F
true
true
这样的,请高手解答,给新手提供下SQL语句,谢谢!

回复

使用道具 举报

千问 | 2010-9-12 13:54:47 | 显示全部楼层
select m.name, decode(sum(decode(m.quanxianid,80,1,0)),0,'F','true') "80",decode(sum(decode(m.quanxianid,90,1,0)),0,'F','true') "90",decode(sum(decode(m.quanxianid,100,1,0)),0,'F','True') "100"from mytable m group by m.name;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行