wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL

Total questions: 18

Worksheet time: 13mins

Name
Class
Date
1.
What word is missing from the line below?
SELECT *
_______ CUSTOMER;
a)
FROM
b)
WHERE
c)
SELECT
d)
ORDER BY
2.
What is the purpose of  *?
a)
Selects ALL fields from the table
b)
Selects only the first field in the table
c)
Selects the last field in the table
d)
Shows only the first row in the table
3.
You must always use _____ when filtering string values.
a)
quotes
b)
astericks
c)
exclamation point
d)
percent signs
4.
What is the correct order of clauses? 
a)
SELECT, FROM, ORDER BY, WHERE
b)
SELECT, FROM, WHERE, ORDER BY
c)
SELECT, WHERE, FROM, ORDER BY
d)
WHERE, FROM, SELECT, ORDER BY
5.
Which clause allows you to SORT data?
a)
ORDER BY
b)
WHERE
c)
FROM
d)
HAVING
6.
Which word allows you to add more than one filter to a SQL query?
a)
AND
b)
BETWEEN
c)
LIKE
d)
EQUALS
7.
Which SQL statement is used to update data in a database?
a)
MODIFY
b)
 SAVE AS
c)
UPDATE
d)
SAVE
8.
Which SQL statement is used to insert new data in a database?
a)
 ADD NEW
b)
 ADD RECORD
c)
 INSERT NEW
d)
 INSERT INTO
9.
With SQL, how do you select all the columns from a table named "Persons"?
a)
 SELECT [all] FROM Persons
b)
 SELECT *.Persons
c)
 SELECT * FROM Persons
d)
 SELECT Persons
10.
Write a code for the following: Return all romances that have an imdb_rating over 6.
a)
SELECT * FROM movies WHERE genre = ‘romance’ AND imdb_rating > 6;
b)
SELECT * FROM movies WHERE genre = ‘romance’ AND imdb_rating < 6;
c)
SELECT imdb_rating, name FROM movie WHERE genre = ‘romance’ AND imdb_rating > 6;
d)
SELECT * FROM movies WHERE genre = romance and imdb_rating < 6;
11.
Return the name and genre of each movie with an imdb_rating greater than 5 and year greater than 2012.
a)
SELECT * FROM movies WHERE imdb_rating > 5 AND year > 2012;
b)
SELECT name, genre FROM movies WHERE imdb_rating < 5 AND year < 2012;
c)
SELECT name, year FROM movies WHERE imdb_rating > 5 year > 2012;
d)
SELECT name, genre FROM movies WHERE imdb_rating > 5 AND year > 2012;
12.
Return 5 movies with an imdb rating of 7 or higher.
a)
SELECT * FROM movies WHERE imdb_rating = 7 limit 5;
b)
SELECT * FROM movies WHERE imdb-rating >= 7 LIMIT 5;
c)
SELECT * FROM movies WHERE imdb_rating <= 7 LIMIT 5;
d)
SELECT * FROM movies WHERE imdb_rating >= 7 LIMIT 5;
13.
Return 8 romances that were made before 1999.
a)
SELECT * FROM movies WHERE genre = ‘romance’ AND year < 1999 LIMIT 8;
b)
SELECT * FROM movies WHERE genre = romance AND year > 1999 LIMIT 8;
c)
SELECT * FROM games WHERE genre = ‘romance’ AND year < 1999 LIMIT 8;
d)
SELECT * FROM Movies WHERE genre = ‘romance’ AND year > 1999 LIMIT 8;
14.
Which of the following code is written correctly?
a)
SELECT * FROM movies WHERE imdb_rating is 1 AND ORDER by desc;
b)
SELECT * FROM movies WHERE genre = ‘comedy’ AND ORDER BY ASC LIMIT 1:
c)
SELECT * FROM movies WHERE genre = ‘horror’;
d)
SELECT * FROM movies genre is horror, and rating is 2;
15.
Write the code for the following: Return all movies made before 2011 and order by the imdb rating from highest to lowest.
a)
RETURN * FROM movies WHERE year < 2011 AND imdb_rating ASC;
b)
SELECT * FROM movies WHERE year > 2011 ORDER BY imdb_rating DESC;
c)
SELECT * FROM movies WHERE year < 2011 ORDER BY imdb_rating DESC;
d)
SELECT * FROM movies WHERE year = 2011 ORDER BY imdb_rating ASC;
16.
What is wrong with the following code: SELECT * FROM movies WHERE genre = comedy AND year < 2016 ORDER BY year DESC;
a)
Comedy should have single quotes around it
b)
AND should be lower case
c)
movies should be capitalized
d)
No changes should be made
17.
What is missing in this code? SELECT * FROM WHERE genre = ‘action’ ORDER BY year ASC;
a)
Missing an AND
b)
Table name
c)
Capitalize action
d)
None of these
18.
Return only the customers who have ER anywhere in their last name. 
a)
last_name LIKE "%er%"
b)
last_name = "%er"
c)
last_name = "%er%"
d)
last_name LIKE "%er"