Ken Kline <[EMAIL PROTECTED]> 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

Reply via email to