General Databases Beginner Basic SQL Query Writing Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 13 | Questions: 20 | Updated: Aug 14, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What does the WHERE clause do in a SQL query?

Explanation

The WHERE clause applies conditions to a query so that only records meeting those conditions are included in the results. It does not sort or group results, nor does it set a row limit.

Submit
Please wait...
About This Quiz
General Databases Beginner Basic SQL Query Writing Quiz - Quiz

Test your foundational SQL skills with this college-level quiz on database fundamentals. Covering SELECT statements, WHERE clauses, joins, and basic data manipulation, this quiz assesses your ability to write and understand essential SQL queries. Ideal for students beginning their database journey or preparing for advanced coursework.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which SQL keyword prevents duplicate values in aggregate results?

Explanation

DISTINCT removes duplicate values before an aggregate function processes them. For example, COUNT(DISTINCT column_name) counts each unique value only once, preventing repeated values from inflating the aggregate result.

Submit

3. Complete: SELECT name FROM students _____ department = 'Engineering'

Explanation

The WHERE clause adds a condition to the query, so only students whose department is 'Engineering' are included in the results. Here, the SELECT statement returns the name of each matching student.

Submit

4. What is the primary key used for?

Explanation

A primary key is a column, or combination of columns, that gives each row in a table a distinct identity. Its values must be unique and cannot be empty, so the database can reliably find and distinguish individual records. Primary keys can also be referenced by other tables to establish relationships between records.

Submit

5. Which operator is used to search for patterns in SQL?

Explanation

LIKE is the SQL operator used to compare a value against a pattern, commonly in a WHERE clause. The percent sign (%) matches any sequence of characters, while the underscore (_) matches a single character. For example, `WHERE name LIKE 'A%'` finds names that begin with A.

Submit

6. Write the SQL keyword to modify existing records: _____ table_name

Explanation

UPDATE modifies existing records in a table. It is typically followed by the table name and a SET clause that specifies the new values, with an optional WHERE clause to limit which records are changed.

Submit

7. What does the AVG() function calculate?

Explanation

AVG() calculates the arithmetic mean of numeric values in a set or column by dividing their total by the number of non-NULL values.

Submit

8. Which SQL statement removes records from a table?

Explanation

`DELETE` removes one or more records (rows) from a table. A `WHERE` clause can specify which rows to remove; without it, all rows are deleted, but the table structure remains intact. `DROP`, by contrast, removes the table itself.

Submit

9. What does LEFT JOIN return?

Explanation

A LEFT JOIN returns every row from the left table, along with matching rows from the right table. If a left-table row has no match, the right-table columns contain NULL values.

Submit

10. Write the SQL keyword to add new records to a table: _____ INTO table_name

Explanation

`INSERT INTO` is the SQL command used to add new records to a table. Specify the table name and, when needed, the columns and values for the new record.

Submit

11. What is the purpose of the DISTINCT keyword?

Explanation

DISTINCT returns only unique rows in a query’s result set, removing duplicate entries based on the selected columns.

Submit

12. Which SQL function counts the number of rows?

Explanation

`COUNT()` returns the number of rows in a query result. It can count all rows with `COUNT(*)` or count non-NULL values in a specified column.

Submit

13. In SQL, what does INNER JOIN do?

Explanation

INNER JOIN combines rows from two tables when the specified join condition matches. Rows without a corresponding match in the other table are excluded from the result.

Submit

14. Which SQL clause is used to sort query results?

Explanation

`ORDER BY` sorts query results based on one or more columns. You can specify `ASC` for ascending order or `DESC` for descending order; if neither is specified, ascending order is typically used by default.

Submit

15. Write the SQL keyword that selects all columns: SELECT _____ FROM table_name

Explanation

The asterisk (*) is a wildcard in SQL. Placing it after `SELECT` requests every column from the specified table, so `SELECT * FROM table_name` returns all columns.

Submit

16. Which SQL keyword is used to retrieve data from a database table?

Explanation

SELECT is the SQL keyword used to query a database table and return specified columns or rows. For example, `SELECT name FROM customers;` retrieves the `name` values from the `customers` table.

Submit

17. Which clause is used to group rows with aggregate functions?

Explanation

GROUP BY organizes rows that share the same values in one or more columns, allowing aggregate functions such as COUNT, SUM, and AVG to calculate results for each group.

Submit

18. Complete: UPDATE employees _____ salary = 60000 WHERE id = 5

Explanation

In an SQL `UPDATE` statement, `SET` introduces the column and value to change. Here, `SET salary = 60000` updates the salary for the employee whose `id` is 5.

Submit

19. Complete the statement: SELECT * FROM employees WHERE salary > 50000 _____ age;

Explanation

AND combines conditions in a WHERE clause, returning only rows where both conditions are true. Here, it connects the salary condition to a condition involving age. For the statement to be complete SQL, age must be followed by a comparison operator and a value, such as `age > 30`.

Submit

20. What does a foreign key establish between tables?

Explanation

A foreign key connects records in one table to corresponding records in another by referencing a key in the other table. This link helps maintain referential integrity, ensuring that references point to existing records rather than creating unrelated data.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What does the WHERE clause do in a SQL query?
Which SQL keyword prevents duplicate values in aggregate results?
Complete: SELECT name FROM students _____ department = 'Engineering'
What is the primary key used for?
Which operator is used to search for patterns in SQL?
Write the SQL keyword to modify existing records: _____ table_name
What does the AVG() function calculate?
Which SQL statement removes records from a table?
What does LEFT JOIN return?
Write the SQL keyword to add new records to a table: _____ INTO...
What is the purpose of the DISTINCT keyword?
Which SQL function counts the number of rows?
In SQL, what does INNER JOIN do?
Which SQL clause is used to sort query results?
Write the SQL keyword that selects all columns: SELECT _____ FROM...
Which SQL keyword is used to retrieve data from a database table?
Which clause is used to group rows with aggregate functions?
Complete: UPDATE employees _____ salary = 60000 WHERE id = 5
Complete the statement: SELECT * FROM employees WHERE salary > 50000...
What does a foreign key establish between tables?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!