agora inbox for pgsql-general@postgresql.org  
help / color / mirror / Atom feed
From: will trillich <will@serensoft.com>
To: pgsql-general@postgresql.org
Subject: Re: Order in CREATE VIEW
Date: Sat, 14 Apr 2001 02:08:05 -0500
Message-ID: <20010414020805.C24922@serensoft.com> (raw)
In-Reply-To: <9b148t$l66$1@news.tpi.pl>
References: <9b148t$l66$1@news.tpi.pl>

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@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!



view thread (5+ messages)  latest in thread

Message-ID: <20010414020805.C24922@serensoft.com>
Permalink:  ../20010414020805.C24922@serensoft.com/
Also on:    postgresql.org/message-id/20010414020805.C24922@serensoft.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: will@serensoft.com
  Subject: Re: Order in CREATE VIEW
  In-Reply-To: <20010414020805.C24922@serensoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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