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

Re: Rewritten queries

From: Jaime Casanova <systemguards(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Rewritten queries
Date: 2004-12-27 19:04:29
Message-ID: 20041227190429.78700.qmail@web50010.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
 --- Keith Worthington <keithw(at)narrowpathinc(dot)com>
escribió: 
> Hi All,
> 
> I wrote a query that created a view and when I
> looked at it in the database
> the SELECT statement was very different.  In part
> 
> SELECT items.id,
>        COALESCE(sales.sum, 0) AS committed,
>        COALESCE(purchases.sum, 0) AS on_order,
>        COALESCE(stock.quantity, 0) AS on_hand
>   FROM peachtree.tbl_item AS items...
> 
> was changed to
> 
> CREATE OR REPLACE VIEW interface.view_inventory AS 
> 
>  SELECT items.id, 
>         CASE 
>             WHEN (sales.sum IS NOT NULL ) THEN
> sales.sum 
>             WHEN (0 IS NOT NULL ) THEN (0 )::real 
>             ELSE NULL::real 
>         END  AS "committed", 
>         CASE 
>             WHEN (purchases.sum IS NOT NULL ) THEN
> purchases.sum 
>             WHEN (0 IS NOT NULL ) THEN (0 )::real 
>             ELSE NULL::real 
>         END  AS on_order, 
>         CASE 
>             WHEN (stock.quantity IS NOT NULL ) THEN
> stock.quantity 
>             WHEN (0 IS NOT NULL ) THEN (0 )::real 
>             ELSE NULL::real 
>         END  AS on_hand 
>    FROM (((peachtree.tbl_item items 
> 
What version of postgres are u using?
I don't see that particular behavior in coalesce.

someone knows if this is the behavior in any older
version of pg?

regards,
Jaime Casanova

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2004-12-27 19:42:25
Subject: Re: Rewritten queries
Previous:From: Jaime CasanovaDate: 2004-12-27 18:59:29
Subject: Re: Rewritten queries

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