File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Query" Watch "SQL Query" New topic

SQL Query

RaviSingh Kumar
Ranch Hand

Joined: Sep 04, 2007
Posts: 52
just want an SQL query for the below mentioned condition.

There are several department having some number of employees.
Want the department id and respective salary for the department having maximum of average salary group by department.

Thanks in advance
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46352
Don't know myself. And I shan't know. We don't simply give out answers to that sort of question. Read this. Please post what you think and I am sure somebody will help.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33107

If you are stuck, try starting with a smaller query. Can you figure out how to write a query to get the highest salary of an individual employee? How about the average salary for a single department? All the departments? etc

When you get stuck, post the last query you were able to write (that solves a smaller problem) and let us know what you got stuck on. This will let people give you more concrete help and will help you learn how to write queries. Handing out an answer doesn't do that.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: SQL Query
It's not a secret anymore!