pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
summary VIEW
2+ messages / 1 participants
[nested] [flat]

* summary VIEW
@ 2002-05-06 11:41 Gary Stainburn <gary.stainburn@ringways.co.uk>
  2002-05-06 13:08 ` Re: summary VIEW Gary Stainburn <gary.stainburn@ringways.co.uk>
  0 siblings, 1 reply; 2+ messages in thread

From: Gary Stainburn @ 2002-05-06 11:41 UTC (permalink / raw)
  To: pgsql-sql

Hi all,

Taking that I have an aircraft seating table, as below,

How could I create a VIEW to replace the capacity table shown underneath?

create table matrix (
  matrixaircraft character varying (4) references aircraft(aircraftid) not 
null,
  matrixrow int4 not null,
  matrixseat character references seating(seatid),
  matrixwidth int4 not null,
  primary key (matrixaircraft, matrixrow)
);

-- capacity should be a VIEW based on matrix
create table capacity (
  capaircraft character varying (4) references aircraft(aircraftid) not null,
  capseat character references seating(seatid) not null,
  capcount int4,
  primary key (capaircraft, capseat)
);


-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: summary VIEW
  2002-05-06 11:41 summary VIEW Gary Stainburn <gary.stainburn@ringways.co.uk>
@ 2002-05-06 13:08 ` Gary Stainburn <gary.stainburn@ringways.co.uk>
  0 siblings, 0 replies; 2+ messages in thread

From: Gary Stainburn @ 2002-05-06 13:08 UTC (permalink / raw)
  To: pgsql-sql

I've managed it by doing:

create view capacity as
  SELECT matrixaircraft AS capaircraft, matrixseat AS capseat,                
    sum(matrix.matrixwidth) AS capcount 
    FROM matrix 
   GROUP BY matrixaircraft, matrixseat;

If there's a better way I'l appreciate being shown.

Ta

Gary

On Monday 06 May 2002 12:41 pm, Gary Stainburn wrote:
> Hi all,
>
> Taking that I have an aircraft seating table, as below,
>
> How could I create a VIEW to replace the capacity table shown underneath?
>
> create table matrix (
>   matrixaircraft character varying (4) references aircraft(aircraftid) not
> null,
>   matrixrow int4 not null,
>   matrixseat character references seating(seatid),
>   matrixwidth int4 not null,
>   primary key (matrixaircraft, matrixrow)
> );
>
> -- capacity should be a VIEW based on matrix
> create table capacity (
>   capaircraft character varying (4) references aircraft(aircraftid) not
> null, capseat character references seating(seatid) not null,
>   capcount int4,
>   primary key (capaircraft, capseat)
> );

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-05-06 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-06 11:41 summary VIEW Gary Stainburn <gary.stainburn@ringways.co.uk>
2002-05-06 13:08 ` Gary Stainburn <gary.stainburn@ringways.co.uk>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox