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

Bad error message

From: Decibel! <decibel(at)decibel(dot)org>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Bad error message
Date: 2008-09-30 21:37:48
Message-ID: 4F0F56A2-8AB0-4121-BE42-1636691CE391@decibel.org (view raw or flat)
Thread:
Lists: pgsql-hackers
 From -HEAD:

ERROR:  aggregates not allowed in WHERE clause
STATEMENT:  SELECT *
                 FROM loans l
                 WHERE id IN (   SELECT max(l.id)
                                     FROM loans
                                         JOIN customers c ON c.id =  
l.customer_id
                                         JOIN people p ON p.id =  
c.person_id
                                     WHERE p.first_name = 'Test person'
                                     GROUP BY l.loan_type_cd
                             )
         ;

The real issue is this:

ERROR:  missing FROM-clause entry for table "l" at character 132
STATEMENT:  SELECT max(l.id)
                                             FROM loans
                                                 JOIN customers c ON  
c.id = l.customer_id
                                                 JOIN people p ON  
p.id = c.person_id
                                             WHERE p.first_name =  
'Test person'
                                             GROUP BY l.loan_type_cd;

And if I change the FROM loans to be FROM loans l, the original  
select does work fine.

Let me know if I need to create a full test case for this...
-- 
Decibel!, aka Jim C. Nasby, Database Architect  decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828


Responses

pgsql-hackers by date

Next:From: Greg StarkDate: 2008-09-30 22:49:17
Subject: Re: Block-level CRC checks
Previous:From: Decibel!Date: 2008-09-30 21:17:10
Subject: Re: Block-level CRC checks

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