pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Kline <ken@oldbs.com>
Cc: Ian Lance Taylor <ian@airs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: greetings
Date: Sat, 24 Feb 2001 17:02:40 -0500
Message-ID: <15301.983052160@sss.pgh.pa.us> (raw)
In-Reply-To: <3A980760.87DAC5AC@oldbs.com>
References: <3A974086.EF665152@oldbs.com>
	<siae7c1tso.fsf@daffy.airs.com>
	<11378.982997569@sss.pgh.pa.us>
	<3A980760.87DAC5AC@oldbs.com>

Ken Kline <ken@oldbs.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



view thread (6+ messages)  latest in thread

Message-ID: <15301.983052160@sss.pgh.pa.us>
Permalink:  ../15301.983052160@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15301.983052160@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ken@oldbs.com, ian@airs.com
  Subject: Re: greetings
  In-Reply-To: <15301.983052160@sss.pgh.pa.us>
  References: <3A974086.EF665152@oldbs.com> <siae7c1tso.fsf@daffy.airs.com> <11378.982997569@sss.pgh.pa.us> <3A980760.87DAC5AC@oldbs.com> <15301.983052160@sss.pgh.pa.us>

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

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