RE: [GENERAL] select and join - Mailing list pgsql-general

From Taral
Subject RE: [GENERAL] select and join
Date
Msg-id 000701bdfeae$6ea4ca60$3b291f0a@taral
Whole thread Raw
In response to select and join  (ZioBudda <michel@michel.enter.it>)
List pgsql-general
> i have make this try:
> esame=> select utente.cognome, prestito.id_utente, libro.tipo,
> count(*) from prestito, libro where libro.id_libro =
> prestito.id_libro and utente.id_utente = prestito.id_utente group
> by id_utente, tipo\g
>
> but the output is :
> ERROR:  parser: illegal use of aggregates or non-group column in
> target list

I keep seeing this... When doing something like this, you must have ALL
non-aggregate columns in the GROUP BY.

So: (note you also forgot to update the FROM)

SELECT utente.cognome, prestito.id_utente, libro.tipo, count(*) FROM
prestito, libro, utente WHERE libro.id_libro = prestito.id_libro AND
utente.id_utente = prestito.id_utente GROUP BY cognome, id_utente, tipo;

Taral


pgsql-general by date:

Previous
From: ZioBudda
Date:
Subject: date null
Next
From: "Taral"
Date:
Subject: RE: [GENERAL] date null