DBMS-Aggregate Methods (GroupBy & Having Class)

DBMS-Aggregate Methods (GroupBy & Having Class)

University

15 Qs

quiz-placeholder

Similar activities

Relational Algebra and Calculus

Relational Algebra and Calculus

University

20 Qs

SQL Commands Mastery Quiz

SQL Commands Mastery Quiz

University

15 Qs

SQL4-Join/aggregate functions/group by

SQL4-Join/aggregate functions/group by

University

19 Qs

Database Design & Development SQL 2

Database Design & Development SQL 2

University

12 Qs

KUIS DAY 3 STACK

KUIS DAY 3 STACK

University

10 Qs

Database Management Systems

Database Management Systems

University

19 Qs

SQL_2

SQL_2

University

20 Qs

SQL and Database Quiz

SQL and Database Quiz

University

15 Qs

DBMS-Aggregate Methods (GroupBy & Having Class)

DBMS-Aggregate Methods (GroupBy & Having Class)

Assessment

Quiz

Computers

University

Hard

Created by

KarunaiMuthu SriRam

Used 1+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following query?

SELECT department_id, SUM(salary)

FROM employees

GROUP BY department_id;

The sum of all salaries in the table.

The sum of salaries for each employee.

The sum of salaries grouped by department_id.

An error because of missing WHERE clause.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about the GROUP BY clause?

It can be used with aggregate functions.

It must be used with a HAVING clause.

It is always used with a WHERE clause.

It cannot be used with ORDER BY clause.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which statement will cause an error?

SELECT department_id, COUNT(*) FROM employees GROUP BY department_id;

SELECT department_id, salary FROM employees GROUP BY department_id;

SELECT department_id, AVG(salary) FROM employees GROUP BY department_id;

SELECT department_id, MAX(salary) FROM employees GROUP BY department_id;

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the HAVING clause in a GROUP BY query?

To filter rows before grouping.

To filter groups after aggregation.

To sort the results of the grouping.

To combine results of two queries.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following queries is valid?

SELECT job_id, SUM(salary) FROM employees GROUP BY job_id, department_id;

SELECT job_id, department_id, SUM(salary) FROM employees GROUP BY job_id;

SELECT job_id, department_id, SUM(salary) FROM employees GROUP BY job_id, department_id;

SELECT job_id, department_id, SUM(salary) FROM employees;

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the result of this query?

SELECT manager_id, COUNT(*)

FROM employees

WHERE department_id = 50

GROUP BY manager_id

HAVING COUNT(*) > 2;

It counts the number of employees for each manager in department 50 where the count is greater than 2.

It groups by department_id and filters the count greater than 2.

It groups by manager_id and department_id and counts employees where count > 2.

It filters employees with count greater than 2 before grouping by manager_id.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the query below, what does it do?

SELECT job_id, AVG(salary)

FROM employees

GROUP BY job_id

ORDER BY AVG(salary) DESC;

Groups employees by job_id and shows average salary.

Groups employees by salary and shows average job_id.

Orders the employees by salary in descending order before grouping.

Groups employees by job_id and shows average salary in ascending order.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?