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

Home -> Community -> Usenet -> comp.databases.theory -> Re: Efficiency; advanced/future SQL constructs

Re: Efficiency; advanced/future SQL constructs

From: Lennart Jonsson <lennart_at_kommunicera.umea.se>
Date: 21 Aug 2001 14:41:35 -0700
Message-ID: <6dae7e65.0108211341.5be42f54@posting.google.com>

"Harlan Messinger" <zzzhmessinger_at_erols.com> wrote in message news:<9lu8mf$3r6$1_at_bob.news.rcn.net>...

[...]

> Here's an example of another routine type of operation. I can write a query
> to get the highest annual salary of any employee in each of my company's
> divisions:
>
> select max(salary) from Employee group by divisionID
>
> But how do I *identify* the highest-paid employees?
>
> select employeeID, name, max(salary) from Employee group by divisionID
>
> obviously doesn't do it, but it would be nice to have something that simple.
> Even more complex though possible not quite as general would be a query to
> return all the records from the Sales table connected with the highest-paid
> employee in each division.
>
> What IS the best way, at this time, to get this information? IS there a
> single SQL statement that does it, in either ANSI SQL or a specific dialect?
>
> I'm curious what similar standard operation types others can think of that
> would be nicely handled by a standard mechanism as well.

Something like

select employeeID, name from Employee where salary = (select max(salary) from Employee)

should work

/Lennart Received on Tue Aug 21 2001 - 16:41:35 CDT

Original text of this message

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