0
我想在cuser表像這樣選擇重複數據並顯示爲表
a_User
___________________
1, Ben,
2, Joe,
3, Tom,
User_group
______________
1, 1,
1, 2,
1, 3,
2, 2,
3, 1,
a_Group
________________
1, All Access,
2, Customer Service,
3, Finance,
所以顯示的數據,它會彈出類似
____________________________________________
Ben, All Access, Customer Service, Finance
Joe, null, Customer Service, null
Tom, All Access, null, null
,而不是我越來越
____________________________________________
Ben, All Access, All Access, All Access,
Ben, Customer Service, Customer Service, Customer Service,
Ben, Finance, Finance, Finance
Joe, Customer Service, Customer Service, Customer Service,
Tom , All Access, All Access, All Access,
我一直在外面的左連接上,但我無法得到列綁定到描述。
select su.usernum,
su.username,
su.descr,
su.email,
sfg1.functiongroup,
sfg2.functiongroup,
sfg3.functiongroup
from a_user su
left outer join User_group suf on su.usernum = suf.usernum
left outer join a_group sfg1 on suf.fgroupnum = sfg1.fgroupnum
left outer join a_group sfg2 on suf.fgroupnum = sfg2.fgroupnum
left outer join a_group sfg3 on suf.fgroupnum = sfg3.fgroupnum
where sfg1.FGROUPNUM = 1
or sfg2.FGROUPNUM = 2
or sfg3.FGROUPNUM = 3;
任何想法將是非常方便的,
覺得我失去了一些東西真的很基本的。
爲了讓你的組從列到行,你必須使用'pivot'我認爲。到目前爲止我沒有使用它,但看看[這裏](http://www.oracle-base.com/articles/11g/pivot-and-unpivot-operators-11gr1.php) – Armunin
大家好,它是oracle 10,希望這可能嗎? –