【问题标题】:How do you get an amount for different locations?您如何获得不同位置的金额?
【发布时间】:2014-05-08 23:41:06
【问题描述】:

我正在尝试为不同的位置获取不同的金额。这是我的查询。

SELECT SUM(a.amount) AS amount, amount (SELECT amount WHERE @location = loc1) loc_amount

有没有其他方法可以做到这一点?

【问题讨论】:

标签: sql select sum


【解决方案1】:

类似

select Sum(s.amount) as TotalAmount From SomeTable s
inner join Select sum(l.amount) as LocationAmount From SomeTable l where l.loc1 = @location

这是一种方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-12
    • 2023-03-15
    • 2021-07-30
    • 1970-01-01
    • 2023-04-04
    • 2021-10-23
    • 2018-09-05
    相关资源
    最近更新 更多