Re: MIN and MAX Query

From: Mike <mike_at_nospam.demon.co.uk>
Date: Wed, 19 Feb 2003 23:16:55 +0000
Message-ID: <6jG$xMBnBBV+Ewds_at_ntlworld.com>


In message <b30v6f$i79$1_at_news7.svr.pol.co.uk>, Matty <matt_at_slippeddisk.fsnenegspamt.co.uk> writes
>Hi All
>
>Just starting out making queries with SQL and have become stumped, and am
>looking for help!
>
>Table is called emp, with the following fields:
>
>EMPNO
>ENAME
>SAL
>
>I need to write a query to show the employees name and salary of the highest
>and lowest salary earner.
>
>I have worked it out to show the highest and lowest salaries but cannot get
>it together with the name!!
>
>I would appreciate your help here!
>
>Many thanks in advance
>
>Matty
>
>

Simplest is

select empno, ename, sal
from emp
where sal = (select max(sal) from emp)

Cheers

Mike

-- 
Mike Cox
Received on Thu Feb 20 2003 - 00:16:55 CET

Original text of this message