Re: Failing query... - Mailing list pgsql-sql

From Tom Lane
Subject Re: Failing query...
Date
Msg-id 6992.966720865@sss.pgh.pa.us
Whole thread Raw
In response to Failing query...  (Shaun <delius@progsoc.uts.edu.au>)
List pgsql-sql
Shaun <delius@progsoc.uts.edu.au> writes:
> SELECT a.auction_id, a.user_id, c.other_names,
>        c.surname, c.email, a.reserve, a.close_time, a.short_desc,
>        a.long_desc, a.start_time,
>        (COALESCE((select MAX(bid) from bid where auction_id = a.auction_id
>        group by auction_id), 0)) as max_bid
> FROM Auction a, Customer c
> WHERE a.user_id = c.user_id
> AND a.auction_id = 754;

Sub-selects inside COALESCE don't work :-(.  This was just fixed about a
week ago --- it will be in 7.1.  In the meantime you might try it the
other way round:
      (select COALESCE(MAX(bid), 0) from bid where auction_id = a.auction_id)      as max_bid
        regards, tom lane


pgsql-sql by date:

Previous
From: Shaun
Date:
Subject: Failing query...
Next
From: Tom Lane
Date:
Subject: Re: Tuple size limit.