d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Sql Question With Joins
Add Reply New Topic New Poll
Member
Posts: 698
Joined: Jun 9 2012
Gold: 5,996.00
Oct 16 2015 11:03am
I have a question from class that requires me to use joins and on clause. I'm still beginner and not sure how to use joins. Here's the question and what I got so far, any help would be appreciated, thanks

Display the department name and Highest, Lowest and Average pay per each department. Name these results High, Low and Avg. Use JOIN and ON form of the syntax. Sort the output so that department with highest average salary are shown first.

Select e.Max(Salary) "high", e.Min(Salary) "low", e.Avg(Salary) "avg", d.Department_Name
From Employees E Join Departments D
on (e.department_id=d.department_id)
Group By E.Department_Id
order by "avg" desc;
Member
Posts: 698
Joined: Jun 9 2012
Gold: 5,996.00
Oct 16 2015 01:28pm
Nevermind I've figured out the problem
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 16 2015 05:49pm
you should always post the error you get.

looks like you should be grouping by the department_name, not department_id, and e.max / e.min / e.avg should just be max / min / avg
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll