AW: Column reference X is ambiguous? - Mailing list pgsql-sql

From Hartwig Jens
Subject AW: Column reference X is ambiguous?
Date
Msg-id 819FEEAC94E6DC459F1FDC83C0C1611F1D7D62@mail2000.b3.dsh.de
Whole thread Raw
List pgsql-sql
Hello Palle,

in my opinion the error message is completely correct. It is not
necessary that GROUP-BY-Attributes have to be included in the
SELECT-Clause.

The following query would be correct either:

SELECT count(*) as count 
FROM read_faq rf,
GROUP BY userid;

I wonder why your query should have run before 7.1.x, even one of my old
test-databases (7.0.2) does not permit a query with ambiguous attributes
in the GROUP-clause.

Best regards, Jens Hartwig

-----------------------------------------------------

T-Systems 
Project Manager
debis Systemhaus GEI GmbH
Address: Eichhornstraße 3, 10785 Berlin
Postal Address: 10785 Berlin
Phone: (004930) 25 54-32 82
Fax: (004930) 25 54-31 87
Mobile: (0170) 167 26 48
E-Mail: jens.hartwig@t-systems.de
Internet: http://www.t-systems.de 


> -----Ursprüngliche Nachricht-----
> Von: Palle Girgensohn [mailto:girgen@partitur.se]
> Gesendet: Montag, 28. Mai 2001 03:37
> An: pgsql-sql@postgresql.org
> Betreff: [SQL] Column reference X is ambiguous?
> 
> 
> Hi!
> 
> SELECT count(rf.userid) as count, rf.userid FROM read_faq rf,
> faq f,
>  deltagare_saved d, person p WHERE rf.id = f.id AND f.kursid=20
> AND
>  d.course_id = f.kursid AND d.userid = rf.userid AND
>  p.userid = d.userid GROUP BY userid
> 
>  ERROR:  Column reference "userid" is ambiguous
> 
> 
> All of the tables have a userid, yes, but this query didn't
> fail before 7.1.x. Is it really OK to fail in this case? I
> thought SQL standard requires all GROUP|ORDER BY arguments to
> acutally exist on the SELECT target list. Then, this makes me
> puzzled... Are the joins making the userids get included in the
> target in some hidden way?
> 
> /Palle
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to 
> majordomo@postgresql.org
> 


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Column reference X is ambiguous?
Next
From: Joachim Trinkwitz
Date:
Subject: Re: Problems with pg_dump (on Debian i386)