Обсуждение: Antw: Re: [SQL] group by / having

Поиск
Список
Период
Сортировка

Antw: Re: [SQL] group by / having

От
"Gerhard Dieringer"
Дата:
> 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