gpt4 book ai didi

MySQL sum 变量之和

转载 作者:行者123 更新时间:2023-11-29 20:26:05 26 4
gpt4 key购买 nike

我将对 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;

我该怎么做?!

最佳答案

如果我是对的,您想要获得平均值总和(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

关于MySQL sum 变量之和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39305081/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com