Re: greetings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ken Kline <ken(at)oldbs(dot)com>
Cc: Ian Lance Taylor <ian(at)airs(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: greetings
Date: 2001-02-24 22:02:40
Message-ID: 15301.983052160@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ken Kline <ken(at)oldbs(dot)com> writes:
> orginally what I wanted to do was this:

> INSERT INTO pledge_classes (semester, year)
> SELECT distinct pseason, pyear from load_bros
> WHERE pyear is not null
> AND pseason is not null
> order by pyear, pseason;

> however pgsql does not allow order by in an INSERT-SELECT statement

Three answers for the price of one ;-) :

1. Why are you trying to constrain the order in an INSERT in the first
place? Tuple order in a table is meaningless under SQL semantics.

2. If you really feel you have to have that, you could rely on the
sorting done implicitly by DISTINCT:

INSERT INTO pledge_classes (year, semester)
SELECT distinct pyear, pseason from load_bros
WHERE pyear is not null
AND pseason is not null;

3. 7.1 will allow you to use an ORDER BY here, pointless though it is.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ian Lance Taylor 2001-02-24 23:15:10 Re: greetings
Previous Message Najm Hashmi 2001-02-24 21:09:06 Controlling Reuslts with Limit