Re: Daily SQL quiz - revisited
Posted in 1993
Jon Rosen — — source: Informix-list mailing list archive (1991-1998)
In article <1993May13.212058.17955@hpcvaac.cv.hp.com> jimf@cv.hp.com (Jim_Fuller) writes:
[munch]
>This isn't elegant, but it seems to work.
>
>
> select key_col, max(sequence) max_seq
> from mytable
> group by key_col
> into temp temptable;>
> select mytable.* from mytable, temptable
> where
> mytable.key_col = temptable.key_col and
> mytable.sequence = temptable.max_seq;
>
Temp tables are NOT in the ANSI SQL-86 or SQL-89 standards. This is a
very vendor-specific solution. On the other hand, a correlated subquery
solves the problem in a single statement with no temp table. See my
other post on this for the answer.
Jon Rosen