Antw: Re: [SQL] group by / having

Поиск
Список
Период
Сортировка
От Gerhard Dieringer
Тема Antw: Re: [SQL] group by / having
Дата
Msg-id s85e0535.081@kopo001
обсуждение исходный текст
Список pgsql-sql
> X Y Z
> 1 1 A
> 1 2 B
> 2 1 C
> 3 1 D
> 3 2 E
> 3 3 F
>
> I want one line for each X value where the Y value is minimal, and I want
> to get the T column also.

select T1.X, T1.Y, T1.Z  from T T1 where T1.Y=(select min(T2.Y)              from T T2             where T1.X = T2.X);

should give you the right answer (not tested)


Gerhard




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] MINUS emulation?
Следующее
От: Vladimir Terziev
Дата:
Сообщение: Re: [SQL] select with group by problem