是否有可能获得总数而不将其返回多行(Group BY)?
例:
数据:
ID Amount Quantity
1 50 1
2 50 2
Run Code Online (Sandbox Code Playgroud)
select sum(Amount) * Quantity, SUM(Quantity) as totalQuantity
from tbl
Run Code Online (Sandbox Code Playgroud)
我希望结果排在第1行:
total totalQuantity
150 3
Run Code Online (Sandbox Code Playgroud)
干得好
SELECT SUM(Amount*Quantity) as total, SUM(Quantity) as totalQuantity
Run Code Online (Sandbox Code Playgroud)