Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: MIN and MAX Query
Hi Again
Thanks for all the replies but I must be doing something stupid cos I get errors in them all.
The result I am looking for from the table is as follows:
ENAME SAL
KING 5000 SMITH 800
But I either get an "error (select max(sal) from emp)" on the different solutions, or get a complete list of all employees with two cols of sal!!!
As I understand it the follwoing gives a complete list
SELECT ENAME, SAL
FROM emp;
I now need the WHERE statement for where SAL is at its highest and lowest. Can u please help as this is starting to bug me!!
BTW I am using Premium Soft MySQL Studio.
Please help!!!!
Matty
"TurkBear" <john.greco_at_dot.state.mn.us> wrote in message
news:e5s95vgr8o7i7b2ik1k9op5v3biinfr0l6_at_4ax.com...
>
> Try something along these lines:
>
> select 'Highest Paid',a.ename,a.sal,
> 'Lowest Paid',b.ename ,b.sal
> from emp a,emp b
> where a.sal = (select max(sal) from emp)
> and b.sal = (select min(sal) from emp)
>
>
> Will need some tweaking to fix any duplicates but should be an approach to
try..
>
>
>
> "Matty" <matt_at_slippeddisk.fsnenegspamt.co.uk> wrote:
>
> >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
> >
>
Received on Thu Feb 20 2003 - 16:17:34 CST
![]() |
![]() |