0% found this document useful (0 votes)
12 views

SQLSoln - GroupRowFunctions

Uploaded by

Mukul Mahadik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

SQLSoln - GroupRowFunctions

Uploaded by

Mukul Mahadik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Group Row Functions

4. select department_id, round(max(salary)) max, round(min(salary)) min,


round(sum(salary)) sum, round(avg(salary)) avg from employees group by
department_id;

5. select job_id, round(max(salary)) max, round(min(salary)) min,


round(sum(salary)) sum, round(avg(salary)) avg from employees group by job_id;

6. select job_id, count(job_id) from employees group by job_id;


select job_id, count(job_id) from employees having job_id='&job_id' group by
job_id;

7. select count(distinct manager_id) "manager count" from employees;

8. select (max(salary) - min(salary)) as DIFFERENCE


from employees;

9. select manager_id, min(salary)


from employees
where manager_id IS NOT NULL
group by manager_id
having min(salary) > 6000
order by min(salary) DESC;

10. select count(*) total,


count(DECODE(to_char(hire_date,'YYYY'), '2000', 'y00')) "2000",
count(DECODE(to_char(hire_date,'YYYY'), '2001', 'y01')) "2001",
count(DECODE(to_char(hire_date,'YYYY'), '2002', 'y02')) "2002",
count(DECODE(to_char(hire_date,'YYYY'), '2005', 'y05')) "2005",
count (*) as "Total"
from employees
where to_char(hire_date,'YYYY') in ('2000','2001','2002','2005')

11. select department_id, job_id, sum(salary) as "TOTAL SALARY"


from employees
where department_id in (20,50,80,90)
group by department_id, job_id
order by 1,2;

12. select count(*) from employees


where last_name like '%n';

13. select d.department_id, d.department_name, count(e.employee_id) as "EMPLOYEE


COUNT"
from employees e, departments d
where e.department_id = d.department_id
group by d.department_id, d.department_name;

14. select department_id,


count(DECODE(to_char(hire_date,'YYYY'), '2000', 'y00')) "2000",
count(DECODE(to_char(hire_date,'YYYY'), '2001', 'y01')) "2001",
count(DECODE(to_char(hire_date,'YYYY'), '2002', 'y02')) "2002",
count(DECODE(to_char(hire_date,'YYYY'), '2003', 'y05')) "2003",
count(*) as TOTAL
from employees
where to_char(hire_date,'YYYY') in ('2000','2001','2002','2003')
group by department_id;

You might also like