Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f1OM2kx08741 for ; Sat, 24 Feb 2001 17:02:46 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f1OM2e915305; Sat, 24 Feb 2001 17:02:40 -0500 (EST) To: Ken Kline cc: Ian Lance Taylor , pgsql-sql@postgresql.org Subject: Re: greetings In-reply-to: <3A980760.87DAC5AC@oldbs.com> References: <3A974086.EF665152@oldbs.com> <11378.982997569@sss.pgh.pa.us> <3A980760.87DAC5AC@oldbs.com> Comments: In-reply-to Ken Kline message dated "Sat, 24 Feb 2001 14:11:28 -0500" Date: Sat, 24 Feb 2001 17:02:40 -0500 Message-ID: <15301.983052160@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200102/387 X-Sequence-Number: 1592 Ken Kline 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