Re: sql question
Date: 1997/12/28
Message-ID: <OyuRbl3E9GA.327_at_nih2naab.prod2.compuserve.com>#1/1
The following query should give you the desired result:
select a.empno, a.empname, a.deptno, a.sal, b.maxi, b.mini from emp a,
(select deptno, max(sal) maxi, min(sal) mini from emp) b
where a.deptno = b.deptno
All the best
Michael A. Istinger
sankaruthra_at_mindspring.com schrieb in Nachricht
<883028172.867237889_at_dejanews.com>...
>Hi everyone,
>I have a strange requirement to accomplish in sql!
>
>ok here it goes,
>
>I have a table say emp with columns ename,empno,dept,sal
>
>I have to select empno,ename,dept, sal and max (sal),min(sal) for each
>employee. the max (sal) should be the max (sal) for employees
>department.
>
>eg:
>
>let's say
>dept 10's max salary = 10000 and min salaray = 100
>
>and
>emp 101 belongs to dept 10
>
>I want to display a record like this
>
>empno ename dept salary max(sal), min(sal)
>____________________________________
>101 joe 101 1000 10000 100
>
>how can I achieve this result!
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Received on Sun Dec 28 1997 - 00:00:00 CET