VIEW's on UNION's

From: Kaare Rasmussen <kar(at)webline(dot)dk>
To: pgsql-general(at)postgreSQL(dot)org
Subject: VIEW's on UNION's
Date: 1999-01-15 07:43:08
Message-ID: 199901150743.IAA08639@bohr.webline.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gilles Darold 1999-01-15 09:01:36 Re: [GENERAL] How to display stored image on web page?
Previous Message Kaare Rasmussen 1999-01-14 22:33:59 Error