I have a Employee table with columns
ename,eid,salary,deptno. How to retrieve sum of salary for
each deptno?

Answer Posted / abhishekjaiswal

select department_id,sum(salary) Dept_wise_salary,job_id from employees group by department_id,job_id
/
Output 
DEPARTMENT_ID DEPT_WISE_SALARY JOB_ID
------------- ---------------- ----------
          110             8300 AC_ACCOUNT
           90            34000 AD_VP
           50            55700 ST_CLERK
           80           243500 SA_REP
          110            12000 AC_MGR
           50            36400 ST_MAN
           80            61000 SA_MAN
           50            64300 SH_CLERK
           20            13000 MK_MAN
           90            24000 AD_PRES
           60            28800 IT_PROG




DEPARTMENT_ID DEPT_WISE_SALARY JOB_ID
------------- ---------------- ----------
          100            12000 FI_MGR
           30            13900 PU_CLERK
          100            39600 FI_ACCOUNT
           70            10000 PR_REP
                          7000 SA_REP
           10             4400 AD_ASST
           20             6000 MK_REP
           40             6500 HR_REP
           30            11000 PU_MAN

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a primary key and a clustered index?

526


What is the difference between left outer join and left join?

516


What is difference between function and trigger?

546


how to fetch common records from two tables? : Sql dba

633


what is the difference between delete and truncate statement in sql? : Sql dba

551






How to pipe multiline string to isql?

580


how many ways to get the current time? : Sql dba

530


What is full form of rtm?

535


How do I truncate a word?

527


Explain the rollback statement?

576


If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????

3550


what is the difference between char_length and length? : Sql dba

574


What is the best partition size for windows 10?

487


What is input buffer in sql*plus?

642


What is java sql package?

536