PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:SQL Execution Order
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, the SQL execution order starts with the SELECT clause.

Q2
True / False

The FROM clause is executed before the WHERE clause in PostgreSQL.

Q3
True / False

In PostgreSQL, the ORDER BY clause is executed before the SELECT clause.

Q4
True / False

The GROUP BY clause in PostgreSQL is executed after the WHERE clause but before the SELECT clause.

Q5
True / False

In PostgreSQL, the HAVING clause is executed before the GROUP BY clause.

Q6
True / False

The LIMIT clause in PostgreSQL is applied after the ORDER BY clause.

Q7
True / False

In PostgreSQL, window functions are executed after the WHERE clause but before the ORDER BY clause

Q8
True / False

The execution of CTEs (Common Table Expressions) in PostgreSQL occurs before the main query execution starts.

Q9
True / False

In PostgreSQL, the DISTINCT keyword is applied after the SELECT clause but before the ORDER BY clause.

Q10
True / False

In PostgreSQL, the SQL execution order of a query with JOIN, WHERE, and GROUP BY clauses is JOIN -> WHERE -> GROUP BY.

Q11
Single Choice

In PostgreSQL, what is the first phase in the SQL execution order?

Q12
Single Choice

Which clause is executed immediately after the FROM clause in PostgreSQL?

Q13
Single Choice

In PostgreSQL, which clause is responsible for filtering rows before the grouping is performed?

Q14
Single Choice

Given the SQL query in PostgreSQL, which step occurs immediately after the WHERE clause?

SQL Code
SELECT column1, SUM(column2)
FROM table1
WHERE column3 > 100
GROUP BY column1;
Q15
Single Choice

In the SQL execution order of PostgreSQL, which clause is evaluated first?

SQL Code
SELECT column1, COUNT(*)
FROM table1
WHERE column2 LIKE 'A%'
GROUP BY column1
ORDER BY column1;
Q16
Single Choice

When using the HAVING clause in PostgreSQL, at what stage is it applied?

Q17
Single Choice

In PostgreSQL, which of the following is the correct SQL execution order?

SQL Code
SELECT column1, COUNT(*)
FROM table1
WHERE column2 > 100
GROUP BY column1
HAVING COUNT(*) > 1
ORDER BY column1;
Q18
Single Choice

How does PostgreSQL handle the ORDER BY clause in relation to the SELECT clause in the execution order?

Q19
Single Choice

Consider the following SQL query in PostgreSQL:

SQL Code
SELECT department, COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY department
HAVING COUNT(*) > 5
ORDER BY department DESC;
Which of the following statements is true about its execution order?
Q20
Single Choice

In the execution order of a complex SQL query in PostgreSQL involving UNION, which step is executed last?

SQL Code
SELECT department FROM employees
UNION
SELECT department FROM managers
ORDER BY department;
Q21
Multiple Choice

Which SQL query correctly demonstrates the execution order in PostgreSQL?

SQL Code
SELECT department, COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY department
HAVING COUNT(*) > 5
ORDER BY department;
Q22
Multiple Choice

In which order does PostgreSQL execute the following query?

SQL Code
SELECT name, AVG(salary)
FROM employees
GROUP BY name
HAVING AVG(salary) > 60000
ORDER BY name;
Q23
Multiple Choice

Which SQL execution order is correct for filtering, grouping, and sorting data in PostgreSQL?

SQL Code
SELECT region, SUM(total_sales)
FROM sales
WHERE total_sales > 1000
GROUP BY region
ORDER BY SUM(total_sales) DESC;
Q24
Multiple Choice

Which SQL execution order is applied when aggregating and sorting data in PostgreSQL?

SQL Code
SELECT customer_id, SUM(order_total)
FROM orders
GROUP BY customer_id
ORDER BY SUM(order_total) DESC;
Q25
Multiple Choice

How does PostgreSQL execute a query involving JOIN, WHERE, and ORDER BY clauses?

SQL Code
SELECT e.name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id
WHERE e.salary > 70000
ORDER BY e.name;
Q26
Multiple Choice

What is the correct execution order for a complex SQL query in PostgreSQL?

SQL Code
SELECT department, COUNT(*) AS employee_count
FROM employees
WHERE hire_date > '2020-01-01'
GROUP BY department
HAVING COUNT(*) > 10
ORDER BY employee_count DESC;
Q27
Multiple Choice

How does PostgreSQL execute a query with multiple aggregate functions and conditions?

SQL Code
SELECT department, AVG(salary), COUNT(*)
FROM employees
WHERE department IN ('Sales', 'Engineering')
GROUP BY department
HAVING AVG(salary) > 60000
ORDER BY COUNT(*) DESC;
Q28
Multiple Choice

In which order does PostgreSQL process a subquery within a SELECT statement?

SQL Code
SELECT name, (SELECT AVG(salary) FROM employees WHERE department = 'Engineering') AS avg_salary
FROM employees
WHERE department = 'Engineering';
Q29
Multiple Choice

Which execution order is followed by PostgreSQL for nested queries?

SQL Code
SELECT employee_id, (SELECT COUNT(*) FROM orders WHERE employee_id = e.employee_id) AS total_orders
FROM employees e
WHERE department = 'Sales';
Q30
Multiple Choice

How does PostgreSQL execute a complex query with multiple joins and conditions?

SQL Code
SELECT e.name, d.department_name, SUM(o.order_total)
FROM employees e
JOIN departments d ON e.department_id = d.department_id
JOIN orders o ON e.employee_id = o.employee_id
WHERE o.order_date > '2023-01-01'
GROUP BY e.name, d.department_name
HAVING SUM(o.order_total) > 10000
ORDER BY e.name;