From: | bartjoosen <bartjoosen(at)hotmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | using count in other column |
Date: | 2009-07-23 09:59:05 |
Message-ID: | 24622738.post@talk.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I made up a query to make a count for each item for each month/year:
SELECT"Artnr_ID", to_char("Date_plan","YYYY") AS "Jaar",
to_char("Date_plan","MM") AS "Maand", Count("tblArtnrs"."Artikelnr") AS
"Monthly_count", "val1","val2","val3"
FROM (("tblAnalyses" INNER JOIN "tblStudies" ON "tblAnalyses"."Studie_ID" =
"tblStudies"."Studie_ID") INNER JOIN "tblFichenr" ON
"tblStudies"."ID_fichenr" = "tblFichenr"."ID") INNER JOIN "tblArtnrs" ON
"tblFichenr"."ID_Art_nrs" = "tblArtnrs"."Artnr_ID"
GROUP BY "tblArtnrs"."Artnr_ID", to_char("Date_plan","YYYY") ,
to_char("Date_plan","MM"), "val1","val2","val3";
Now I want to use the "Monthly_count" value for further calculations with
other columns.
I tried to use
"Monthly_count"+ "val1" + "Monthly_count" * "val2" + "Monthly_count" *"val3"
But "Monthly_count" is not recognised in my calculations.
How can this be solved?
Thanks
Bart
--
View this message in context: http://www.nabble.com/using-count-in-other-column-tp24622738p24622738.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2009-07-23 10:55:16 | Re: Bit by "commands ignored until end of transaction block" again |
Previous Message | Glenn Maynard | 2009-07-23 08:23:29 | Re: Need magical advice for counting NOTHING |