Introduction to Advanced SQL Joins and Query Optimization
Explore advanced SQL joins and basic query optimization techniques.
Questions in this quiz
15 questions on Introduction to Advanced SQL Joins and Query Optimization. Work through them here, then start the quiz to answer them and see your score.
1.What is the primary purpose of using a LEFT JOIN in SQL?
- ATo combine rows from two tables, returning all rows from the right table and matched rows from the left table.
- BTo combine rows from two tables, returning all rows from the left table and matched rows from the right table.
- CTo combine rows from two tables, returning only matching rows.
- DTo combine rows from two tables, returning only unmatched rows.
2.Which SQL clause is used to filter records in a query?
- AWHERE
- BORDER BY
- CSELECT
- DJOIN
3.What is an INNER JOIN used for in SQL?
- ATo return all rows from the right table and matched rows from the left table.
- BTo return all rows from the left table and matched rows from the right table.
- CTo return all rows from both tables, including unmatched rows.
- DTo return only the rows with matching values in both tables.
4.Which of the following can improve query performance?
- AAdding indexes to frequently queried columns.
- BAvoiding the use of WHERE clauses.
- CUsing SELECT * to retrieve all columns.
- DUsing complex subqueries in every query.
5.What does the SQL UNION operator do?
- AReturns the difference between two queries.
- BCombines the results of two queries, removing duplicates.
- CReturns only the common rows from two queries.
- DCombines the results of two queries, including duplicates.
6.Which SQL keyword is used to sort the result-set?
- AORDER BY
- BGROUP BY
- CFILTER BY
- DSORT BY
7.What is a CROSS JOIN in SQL?
- AA join that returns all rows from the right table and matched rows from the left table.
- BA join that returns only matched rows from both tables.
- CA join that returns all possible combinations of rows from two tables.
- DA join that returns all rows from the left table and matched rows from the right table.
8.Which SQL function is used to count the number of rows in a result-set?
- AAVG()
- BMAX()
- CSUM()
- DCOUNT()
9.What is the purpose of the SQL DISTINCT keyword?
- ATo group rows that have the same values.
- BTo remove duplicate rows from the result-set.
- CTo sort the result-set in descending order.
- DTo select all columns from a table.
10.Which SQL clause is used to group rows that have the same values?
- AWHERE
- BHAVING
- CORDER BY
- DGROUP BY
11.What is the purpose of the SQL HAVING clause?
- ATo filter records after grouping.
- BTo sort records in ascending order.
- CTo join two tables.
- DTo filter records before grouping.
12.Which SQL statement is used to remove a table from a database?
- ADELETE TABLE
- BREMOVE TABLE
- CTRUNCATE TABLE
- DDROP TABLE
13.What is the purpose of using an index in SQL?
- ATo store data in a table.
- BTo define relationships between tables.
- CTo enforce unique constraints on a column.
- DTo improve the speed of data retrieval operations.
14.Which SQL keyword is used to remove duplicate values from a column?
- AUNIQUE
- BDISTINCT
- CREMOVE
- DFILTER
15.What does the SQL EXPLAIN statement do?
- AIt creates a new table in the database.
- BIt updates records in a table.
- CIt provides information about how a SQL statement will be executed.
- DIt executes a query and returns results.