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.
我有一个“TableA带有字段”的“ A, B, C, Bytes, Entrada_Saida”,需要在同一个查询中返回一个Sum(Bytes)when"Entrada_Saida = Entrada"和另一个 when "Entrada_Saida = Saida",分组依据A, B, C, Entrada_Saida, Bytes。
TableA
A, B, C, Bytes, Entrada_Saida
Sum(Bytes)
"Entrada_Saida = Entrada"
"Entrada_Saida = Saida"
A, B, C, Entrada_Saida, Bytes
尝试但保持“此子查询最多可以返回一条记录”错误。
如果要在同一行中返回两个总和,可以使用如下查询:
SELECT A, B, C, SUM(IIF(Entrada_Saida='Entrada',Bytes,0)) Bytes_Entradas, SUM(IIF(Entrada_Saida='Saida',Bytes,0)) Bytes_Saidas FROM Yourtable GROUP BY A, B, C