Chapter 6 Application Flashcards

1
Q

Prepare a summary query that uses COUNT(*) on Employee, and AVG(), SUM(), MIN(), and MAX() on the Employee.salary column.

A

select COUNT(*) as Number_of_Employees, round(AVG(salary),2) as avg_salary,SUM(salary) as Total_Salary, MAX(salary) as Highest_Salary, MIN(salary) as Lowest_Salary from employee;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Code a summary query that works on a non-numeric column such as hiredate. Explain what the result indicates.

A

Select Min(hireDate) as Earliest_HireDate from employee;

Result shows the first person hired in the list of employees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a summary query on Employee using the DISTINCT keyword when counting the different jobs supervised by manager 7698 and also computes average salary for that manager’s employees.

A

select count(DISTINCT empno) as Number_of_Employees, round(avg(salary),2) as Avg_Salary from employee where manager = 7698;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Prepare a summary query that calculates the maximum salary by department.

A

select deptno, max(salary) from employee group by deptno;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Code a summary query that calculates average salary for those departments that have three or more employees.

A

select deptno, round(avg(salary),2) as Avg_Salary from employee group by deptno having count(deptno) > 3;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write a select statement to produce a summary query with a compound condition in the having clause to count the number of employees in department 20 with a job in the list (‘ANALYST’, ‘CLERK’).

A

select count(*) as NumEmpInDept, job, deptno from employee where deptno = 20 group by job having job = ‘clerk’ or job = ‘analyst’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly