Re: Order in CREATE VIEW

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Order in CREATE VIEW
Date: 2001-04-14 07:08:05
Message-ID: 20010414020805.C24922@serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Apr 11, 2001 at 10:25:24AM +0200, Marcin Wasilewski wrote:
> hello everybody,
> Can you help me?
>
> I have POSTGRESQL 7.0.3,
> I try to create simple view by typing.
>
> create view "xx" as select "aa.yy", "bb.yy" from "yy" order by "bb.yy"
>
> the problem is that parameter order is not implemented with create view.
> so how can I create such simple query??

unless your table "yy" has fields "aa.yy" and "bb.yy" (or
something like "first name" or "client's phone") i'd start by
revising that to something like:

create view
"xx" as
select
"aa"."yy",
"bb"."yy"
from
"yy"
order by
"bb"."yy"
;

but even there you still have problems:

table aa field yy
table bb field yy
-> the names will collide (two fields named yy in the view)

plus, there's no definition of how the two tables relate to each
other.

not knowing what your example is based on, how about something
like this...

create view
xx as
-- and here comes a regular old SELECT statement:
select
aa.yy as aa_yy_or_whatever,
bb.yy as bb_yy_you_get_the_idea
from
aa,
bb
where
aa.somefield = bb.otherfield
order by
bb.yy
;

--
americans should never read anything so subversive as what's at
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html

will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message will trillich 2001-04-14 07:21:10 Re: Help on PGSQL
Previous Message Oliver Elphick 2001-04-14 06:23:51 Re: Order in CREATE VIEW