0
votes

i have a column which is a sum of a group by. i want to multiply this column to another column using the following query. I tried using a subquery but it does not work.

SUM("subq.public"."fpProjects"."capitalTotalSpent")*"public"."currencyYears".curRate"
FROM(
SELECT
Sum("public"."fpProjects"."capitalTotalSpent") AS "total capital spent",
FROM
"public"."fpProjects"

I get a syntax error here "Sum("public"."fpProjects"."capitalTotalSpent") AS "total cap"

1
Did you have a chance to try my answer?jpw
I did try but I still got an errorKarin Vrijburg
Can you post the whole query, and the table definitions? That would really help to solve it. That is if you still need help.jpw
thank you. But i think it has worked.:)Karin Vrijburg

1 Answers

0
votes

Not sure about your actual table names, but I think something like this is what you want:

SELECT SUM(subq.sum_total_capital_spent) * curRate)
FROM public.currencyYears, (
  SELECT Sum(capitalTotalSpent) AS sum_total_capital_spent FROM public.fpProjects
) subq