Skip site navigation (1) Skip section navigation (2)

Putting an aggregate value in an UPDATE statement...

From: John Gage <jsmgage(at)numericable(dot)fr>
To: NOVICE Postgres elist <pgsql-novice(at)postgresql(dot)org>
Subject: Putting an aggregate value in an UPDATE statement...
Date: 2010-06-01 20:28:36
Message-ID: 4769D3C0-C894-4CBE-8318-467303665862@numericable.fr (view raw or flat)
Thread:
Lists: pgsql-novice
This statement:


UPDATE question_choices SET total_rows = count(*) from care_lesson;


returns the following error (which is well-documented):


ERROR:  cannot use aggregate function in UPDATE
LINE 1: UPDATE question_choices SET total_rows = count(*) from care_...


I wondered how I can put a row count from one table into another?  I  
can't figure it out.

Thanks very much,

John Gage


Responses

pgsql-novice by date

Next:From: Mariateresa LDate: 2010-06-01 20:33:51
Subject: Re: sql files in psql ?
Previous:From: Jeanne Louize EmygdioDate: 2010-06-01 12:16:59
Subject: Invitation to connect on LinkedIn

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group