假设我有这张使用查询获得的表
我正在处理一个可以给出这样的查询
这是我迄今为止尝试过的:
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 子句中。
将 'Wins' 和 'Competition' 列放在 GROUP BY 子句中不会给出我想要的结果。
还有其他建议吗?
提前致谢