0
Dept_No (Int)
Dept_Name (Char(30))

and using the following database:

EMPLOYEE (fmane, minit, lname, ssn, birthdate, address, sex, salary, superssn, dno)     KEY: ssn
DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate)               KEY: dnumber.
PROJECT  (pname, pnumber, plocation, dnum)                          KEY: pnumber.

I'm stuck at right now, want give me some advice on starting it? really don't know where to start

Lin Wei
  • 87
  • 1
  • 5

1 Answers1

0
Select e.Dept_No, d.Dept_Name, Count(e.Dept_No), 
SUM(e.salary) as Sum_Salary,
AVG(e.salary)  as AVE_Salary
from EMPLOYEE e
join DEPARTMENT d ON e.dno = d.dnumber
Group by e.Dept_No, d.Dept_Name
  • First you need to join dept and emp tables.
  • Since you need total salary by dept you have to group by dept no
  • also you want to show dept_name so you have to group by it as well
  • If you have columns except functions(avg,sum.. etc) you have to add these columns group by statement.
Burak Karasoy
  • 1,682
  • 2
  • 21
  • 33
  • also can I email you? I just have one minor question left, too long to post on here – Lin Wei Dec 01 '15 at 00:47
  • Sharing e mail here may not be legal so you had better prepare your question's summary with nice explanation.I help if i can. – Burak Karasoy Dec 01 '15 at 01:05
  • okay thanks, are there anyway to contact you? what I mean I was I will post my code here maybe using a new question and see if you can answer. Please consider help me, thank you – Lin Wei Dec 01 '15 at 01:20
  • I don't know if any contact way exist. I will be checking your activity to see your question but be sure that there are a lot of people who can help you in so. – Burak Karasoy Dec 01 '15 at 01:29