NEW
Font size
WorksheetsPRE-TEST (SQL Filtering, Functions, and Grouping)
Total questions: 30
Worksheet time: 30mins
Choose the letter of the correct answer. Which SQL constraint ensures that a column cannot have an empty value?
UNIQUE
CHECK
NOT NULL
PRIMARY KEY
Choose the letter of the correct answer. What does NULL represent in SQL?
Zero
No value or unknown
Blank space
Empty string
Choose the letter of the correct answer. Which operator is used to check if a column contains NULL?
= NULL
IS NULL
== NULL
HAS NULL
Choose the letter of the correct answer. Which SQL clause is used to filter rows before grouping?
HAVING
WHERE
GROUP BY
ORDER BY
Choose the letter of the correct answer. Which SQL clause is used to filter grouped results?
WHERE
ORDER BY
HAVING
DISTINCT
Choose the letter of the correct answer. Which of the following is an aggregate function?
CONCAT()
ROUND()
SUM()
SUBSTR()
Choose the letter of the correct answer. What does the GROUP BY clause do?
Sorts results
Arranges rows with the same values into groups
Filters aggregated results
Deletes duplicate rows
Choose the letter of the correct answer. Identify the correct syntax for using GROUP BY:
SELECT col FROM table HAVING col;
SELECT col FROM table GROUP col;
SELECT col, SUM(col) FROM table GROUP BY col;
SELECT col WHERE col GROUP BY table;
Choose the letter of the correct answer. Which command permanently saves changes made to a database?
SAVE
COMMIT
APPLY
UPDATE
Choose the letter of the correct answer. Which command undoes unsaved changes?
CANCEL
ROLLBACK
UNDO
REVERT
Choose the letter of the correct answer. Which statement is used to add a new column?
ALTER TABLE ADD COLUMN
UPDATE TABLE ADD
MODIFY TABLE ADD
CREATE TABLE ADD
Choose the letter of the correct answer. Which SQL command modifies the datatype of an existing column?
ALTER TABLE CHANGE
ALTER TABLE MODIFY
UPDATE COLUMN
ALTER TABLE DATA
Choose the letter of the correct answer. Which SQL command is used to rename a column?
ALTER TABLE RENAME COLUMN
ALTER TABLE CHANGE
RENAME TABLE
MODIFY COLUMN
Choose the letter of the correct answer. A view in SQL is best described as:
A physical table
A backup file
A saved SELECT query
A temporary table
Choose the letter of the correct answer. Which command is used to create a view?
CREATE VIEW
MAKE VIEW
ADD VIEW
INSERT VIEW
Choose the letter of the correct answer. Which function returns the number of rows?
SUM()
COUNT()
AVG()
TOTAL()
Choose the letter of the correct answer. Which function returns the average value?
AVG()
MEAN()
COUNT()
DIV()
Choose the letter of the correct answer. Which is TRUE about FOREIGN KEY?
It uniquely identifies each row in a table
It references the primary key from another table
It allows duplicate NULL values
It deletes the referenced table automatically
Choose the letter of the correct answer. What happens if you insert NULL into a NOT NULL column?
The value is converted to zero
It is allowed
SQL returns an error
The row is skipped
Choose the letter of the correct answer. Which clause must be used with aggregate functions to group results?
DISTINCT
GROUP BY
WHERE
ORDER BY
Write T if the statement is true and F if false: NULL is the same as zero in SQL.
True
False
Write T if the statement is true and F if false: WHERE filters data before grouping.
True
False
Write T if the statement is true and F if false: HAVING filters data after grouping.
True
False
Write T if the statement is true and F if false: A view physically stores data in the database.
True
False
Write T if the statement is true and F if false: COMMIT saves all changes permanently.
True
False
Write T if the statement is true and F if false: ROLLBACK can undo changes even after COMMIT.
True
False
Write T if the statement is true and F if false: ALTER TABLE can add and delete columns.
True
False
Write T if the statement is true and F if false: COUNT(*) counts all rows, including NULL values.
True
False
Write T if the statement is true and F if false: PRIMARY KEY columns can contain NULL values.
True
False
Write T if the statement is true and F if false: GROUP BY is always required when using aggregate functions.
True
False
