Re: A VERY DIFFICULT QUERY

From: KyoHeung Park <kyoheung_at_sr.sindo.co.kr>
Date: Thu, 15 Jul 1999 08:47:35 GMT
Message-ID: <378DA03F.72538FB1_at_sr.sindo.co.kr>


select a.*
  from emp a, (select avg(sal) avg_sal from emp) b  where ( a.sal - b.avg_sal ) =
(select min( abs(c.sal - d.avg_sal) )
  from emp c, (select avg(sal) avg_sal from emp) d ) /

nooruddin wrote:
>
> Hi!
>
> I want a sql query for the following result:
>
> From a table containing salaries (say emp table)
>
> I want the salary which is closest to the average of all the
> salaries
> (it seems easy at first look, but I assure you its not the case)
>
> NOTE:The query should be an sql statement and not a pl/sql script.
> good luck..
>
> bye..
Received on Thu Jul 15 1999 - 10:47:35 CEST

Original text of this message