Re: WHERE on an alias

Поиск
Список
Период
Сортировка
От A_Schnabel@t-online.de (Andre Schnabel)
Тема Re: WHERE on an alias
Дата
Msg-id 003001c13053$a3c4ff60$0201a8c0@aschnabel.homeip.net
обсуждение исходный текст
Ответ на WHERE on an alias  (Joseph Shraibman <jks@selectacast.net>)
Список pgsql-sql
----- 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: List archives moved and cleaned up ...
Следующее
От: "Vladimir Terziev"
Дата:
Сообщение: