pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A_Schnabel@t-online.de
To: Joseph Shraibman <jks@selectacast.net>
To: ML: Postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: WHERE on an alias
Date: Wed, 29 Aug 2001 08:27:12 +0200
Message-ID: <003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net> (raw)
References: <web-109210@davinci.ethosmedia.com>
	<3B8AD867.3080007@selectacast.net>
	<13357.998962545@sss.pgh.pa.us>
	<3B8BFFAF.6050909@selectacast.net>

----- Original Message -----
From: "Joseph Shraibman" <jks@selectacast.net>
Subject: Re: [SQL] WHERE on an alias


> If I try to put a distinct on in my subselect int the from I get:
>
> ERROR:  SELECT DISTINCT ON expressions must match initial ORDER BY
expressions
>
> what does that mean?

You need to (at least)  ORDER BY  the expression you want to have the
DISTINCT ON.

Tom's example would work fine:

> > select distinct on (ml.f1,ml.f2) * from ut,ml
> > where ut.f1 = ml.f1 and ut.f2 = ml.f2
> > order by ml.f1, ml.f2, ml.f3 desc;

Wrong:

select distinct on (ml.f1,ml.f2) * from ut,ml
where ut.f1 = ml.f1 and ut.f2 = ml.f2
order by ml.f2, ml.f1, ml.f3 desc;


Andre




view thread (9+ messages)

Message-ID: <003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net>
Permalink:  ../003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net/
Also on:    postgresql.org/message-id/003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: A_Schnabel@t-online.de, jks@selectacast.net
  Subject: Re: WHERE on an alias
  In-Reply-To: <003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net>

* 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