Re: Daily SQL quiz - revisited
Posted in 1993
Topics: SQL Development & Query Writing
In article <1993May13.170650.27426@wvus.org>, sford@wvus.org (Scott Ford) writes:
|>Thanks to all who contributed to the SQL quiz -- trying to get a number
|> ...
|>Perhaps I can simplify the question (albeit not the resolution, however):
|>
|>Say we have a table that contains many rows. For each row, we have a
|>column called "sequence", such that we could have the following:
|>
|> key_col sequence many other columns
|> ------- -------- ------------------
|> 16 1
|> 16 2
|> 17 1
|> 17 2
|> 17 3...
|>
|>However, what do we do if we want the current records for each of the
|>different key values. This is the basic challenge of the SQL quiz.
what about the following:
select * from mytable
group by key_col
having sequence = max(sequence)
David
--
David Silberberg Internet: davids@stsci.edu
Space Telescope Science Institute SPAN: SCIVAX::DAVIDS
3700 San Martin Drive ATTnet: (410)516-5142
Baltimore, Maryland 21218