Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lovray
Starting Member
9 Posts |
Posted - 2009-06-25 : 17:43:42
|
| I need the average employee salary for each department.Include the Manager's name and Department description.from these 3 tables:EMPLOYEE (key:EMP_ID, FIELDS:EMP_NAME,EMP_SALARY), DEPARTMENT (key:DPT_ID,fields:DPT_DESC, EMP_ID, foreign keys:EMP_ID (department manager’s EMP_ID) )and EMPLOYEE_DEPARTMENT(foreign keys:EMP_ID,DPT_ID)much thanks |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-06-26 : 01:37:23
|
| select ed.dpt_id,avg(emp_salary) as avgfrom employee e inner join department d d.emp_id = e.emp_idinner join employee_department ed on ed.dpt_id = d.dpt_idgroup by ed.dpt_id |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-06-26 : 07:07:11
|
| That doesn't include the manager's name. I did his homework for him in another thread, exact same question, and he still hasn't answered about the manager's name. Maybe if he keeps posting the question he'll get the right answer!Jim |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-06-26 : 12:04:34
|
| Perhaps this is another chance to write the world's most convoluted query using every system table possible. That way it will be acceptably "Enterprizy"[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-26 : 13:44:11
|
quote: Originally posted by lovray I need the average employee salary for each department.Include the Manager's name and Department description.from these 3 tables:EMPLOYEE (key:EMP_ID, FIELDS:EMP_NAME,EMP_SALARY), DEPARTMENT (key:DPT_ID,fields:DPT_DESC, EMP_ID, foreign keys:EMP_ID (department manager’s EMP_ID) )and EMPLOYEE_DEPARTMENT(foreign keys:EMP_ID,DPT_ID)much thanks
make a try atleast before posting homework questions. otherwise you wont gain anything |
 |
|
|
|
|
|
|
|