Re: Beginner's question
From: Andrew Finkenstadt <andy_at_vistachrome.com>
Date: Fri, 26 Feb 1993 14:52:44 GMT
Message-ID: <C329Bw.8Bo_at_vistachrome.com>
Date: Fri, 26 Feb 1993 14:52:44 GMT
Message-ID: <C329Bw.8Bo_at_vistachrome.com>
rtan_at_.uts.amdahl.com (Rick Tan) writes:
>Hi,
>I need to retrieve a row from a table. The row selected must have the
>largest value in a field. What SQL statement will do the trick?
>Thanks in advance for any help.
>Rick
You need to retrieve the entire row which contains the highest value in one specific column?
The highest value in a column:
select max(column) from table;
The row with the highest value in a column:
select * from table
where column = (select max(column) from table)
This MAY return more than one row if two-or-more rows have the same value in column that happens to be the highest value.
-- Andrew Finkenstadt, Vista-Chrome, Inc., Homes & Land Publishing Corporation GEnie Unix RoundTable Manager, andy_at_vistachrome.com, andy_at_genie.geis.com. "[The author] neither accidentally nor intentionally omits or includes anything that could support a preconceived thesis." - C&EN 21-DEC-92 p.72Received on Fri Feb 26 1993 - 15:52:44 CET