我有一个看起来像这样的表:
Name | Type
Maurice | Gold
Lisa | Gold
Andrew | Silver
Matthew | Platinum
Sarah | Gold
Peter | Platinum
Franco | Platinum
Patrick | Silver
我一直在尝试使用'选择'按类型显示它们,但我没有找到任何正确的方法。我看的结果是这样的:
Silver | Gold | Platinum
Andrew | Maurice | Matthew
Patrick | Lisa | Peter
NULL | Sarah | Franco
反正有没有让结果看起来像那样?谢谢!
答案 0 :(得分:0)
select (case when type='Silver' then name end) as silver,
(case when type='Gold' then name end) as gold,
(case when type='Platinum' then name end) as platinum
from table_name