Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: A VERY DIFFICULT QUERY

Re: A VERY DIFFICULT QUERY

From: Jarek Palka <jarek_at_kamsoft.com.pl>
Date: Thu, 15 Jul 1999 08:33:46 +0200
Message-ID: <378D80CA.90A0EAE6@kamsoft.com.pl>


> 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

Try this :

SELECT salary from
(select avg(salary) "AVG" from salaries),salaries where abs(AVG-salary)=(select min(abs(AVG-salary)) from salaries)



Jaroslaw Palka <jarek_at_kamsoft.com.pl> P.I.KAMSOFT, Katowice tel. (+48 32) 255-59-93, 209-07-05, fax 209-07-15 POLAND Received on Thu Jul 15 1999 - 01:33:46 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US