我已经查看了整个网站,但找不到解决我的问题的方法。我试图尽可能地抽象它。
我的查询是这样的:
select sup, a, b, c, d
from
(
select sup, a, 0, 0, 0 from x where y = 1 group by sup
union
select sup, 0, b, 0, 0 from x where y = 2 group by sup
union
select sup, a, 0, c, 0 from x where y = 3 group by sup
union
select sup, a, 0, 0, d from x where y = 4 group by sup
)
Run Code Online (Sandbox Code Playgroud)
这工作正常,我得到了我期望的结果。
但
我想要的是将这些结果分组在 sup 列中。当我GROUP …