2
比方說,我有這個表,我開始使用查詢重新分組的多行成一個
我工作的查詢,可以給像這樣
這是我到目前爲止所嘗試的:
Select [First Name], [Last Name], Club,
case when Competition='La Liga' then Wins end as [La Liga],
case when Competition='Copa del Rey' then Wins end as [Copa del Rey],
case when Competition='Supercopa de Espana' then Wins end as [Supercopa de Espana],
case when Competition='UEFA Champions League' then Wins end as [UEFA Champions League],
case when Competition='UEFA Super Cup' then Wins end as [UEFA Super Cup],
case when Competition='FIFA Club World Cup' then Wins end as [UEFA Super Cup]
From dbo.Table
Group by [First Name], [Last Name], Club
但我得到'SQL執行錯誤'列'dbo.Wins'在選擇列表中無效,因爲它不包含在聚合函數或GROUP BY子句中。 列'dbo.Competition'在選擇列表中無效,因爲它不包含在聚合函數或GROUP BY子句中。
在GROUP BY子句中放置列'Wins'和'Competition'不會給出我想要的結果。
其他建議?
在此先感謝
謝謝你的@dasblinkenlight – Zack09