Re: Order in CREATE VIEW

Поиск
Список
Период
Сортировка
От will trillich
Тема Re: Order in CREATE VIEW
Дата
Msg-id 20010414020805.C24922@serensoft.com
обсуждение исходный текст
Ответ на Order in CREATE VIEW  ("Marcin Wasilewski" <marcingrupy@poczta.onet.pl>)
Список 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@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

В списке pgsql-general по дате отправления:

Предыдущее
От: Jeff Eckermann
Дата:
Сообщение: Backend sent D message without prior T
Следующее
От: nospam@nospam.nospam (Steve Jorgensen)
Дата:
Сообщение: How to get libpq.dll for 7.1 RCs