This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
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

Win a copy of The Software Craftsman this week in the Agile forum!
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: 41601
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: 31680

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Have you tried LearnNowOnline?
subject: SQL Query