VIEW's on UNION's - Mailing list pgsql-general

From Kaare Rasmussen
Subject VIEW's on UNION's
Date
Msg-id 199901150743.IAA08639@bohr.webline.dk
Whole thread Raw
In response to Re: [GENERAL] two questions  (Tim Williams <williams@ugsolutions.com>)
List pgsql-general
I miss <subject>. I know the answer is that I can write them myself,
but I don't know where to start or end.

See this construct:
CREATE TABLE gl-amount (
    glam_nr int,
    period date,
    entry_amount numeric(9,0),
    PRIMARY KEY (glam_seq,period)
    );

CREATE VIEW glam_curmth_v AS
    SELECT entry_amount AS amount1 FROM gl-amount
    WHERE date_part(year', period) = date_part('year', now::datetime)
    AND date_part('month', period) = 1
    UNION SELECT entry_amount AS amount2 FROM gl-amount
    WHERE type = 'S' AND  period = 2;

   SELECT entry_amount AS amount1 FROM gl-amount
    WHERE date_part('year', period) = date_part('year', 'now'::datetime)
    AND date_part('month', period) = 1
    UNION SELECT entry_amount AS amount2 FROM gl-amount
    WHERE date_part('year', period) = date_part('year', 'now'::datetime)
    AND date_part('month', period) = 2
    ...

Can it be done without the use of VIEW's on UNION's?


pgsql-general by date:

Previous
From: Oleg Broytmann
Date:
Subject: Re: [GENERAL] How to display stored image on web page?
Next
From: Memphisto
Date:
Subject: Representation of big integer numbers.