Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 A 列和 Z 列的表。
我在这张桌子上做一个 SELECT,总结 A。
如果列 Z = 1,我想 sum(A) 为“B”,如果列 Z = 2,我想 sum(A) 为“C”。我该怎么做呢?
案例陈述SUM...
SUM
Select Sum(Case When Z = 1 Then A Else 0 End) As B, Sum(Case When Z = 2 Then A Else 0 End) As C From TableName