我将对totalSale
变量求和并将其存储为balanced
:
这是我的问题:
SELECT
sum((price * content.owner_percent) / 100) AS totalSale,
sum(totalSale) as balanced
FROM customer_content
INNER JOIN content ON content.id = customer.content_id
WHERE content_owner_id = 3;
我该怎么做?!
答案 0 :(得分:0)
如果我是对的,你想获得平均值(totalSale
)的总和。
如果是,你可以这样做:
SELECT sum(src.totalSale) as balanced
FROM (
SELECT
sum((price * content.owner_percent) / 100) AS totalSale,
FROM customer_content
INNER JOIN content ON content.id = customer.content_id
WHERE content_owner_id = 3
) AS src