我有一个列是一个组的总和。我想使用以下查询将此列乘以另一列。我尝试使用子查询,但它不起作用。
SUM("subq.public"."fpProjects"."capitalTotalSpent")*"public"."currencyYears".curRate"
FROM(
SELECT
Sum("public"."fpProjects"."capitalTotalSpent") AS "total capital spent",
FROM
"public"."fpProjects"
我在这里得到语法错误" Sum(" public"。" fpProjects"。" capitalTotalSpent")AS"总上限&# 34;
答案 0 :(得分:0)
不确定您的实际表名,但我认为这样的内容是您想要的:
SELECT SUM(subq.sum_total_capital_spent) * curRate)
FROM public.currencyYears, (
SELECT Sum(capitalTotalSpent) AS sum_total_capital_spent FROM public.fpProjects
) subq