wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL - sys vars & filters

Total questions: 22

Worksheet time: 15mins

Name
Class
Date
1.

If you were wanting to filter data, which clause would you use?

a)

Where

b)

Order by

c)

From

d)

Select

2.

Using which word allows you to specify that more than one condition must be met in a query?

a)

Also

b)

And

c)

Or

d)

Where

3.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

4.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

5.

With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?

a)

SELECT * FROM Items ORDER BY Price ASCENDING

b)

SELECT * FROM Items ORDER BY Price ASC

c)

SELECT * FROM Items BY Price LOWEST TO HIGHEST

d)

SELECT * FROM Items ORDER BY Price DESC

6.

Which SQL function is used to count the number of rows in a SQL query?

a)

COUNT()

b)

NUMBER()

c)

SUM()

d)

COUNT(*)

7.

If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default

a)

ASC

b)

DESC

c)

There is no default value

d)

None of the mentioned

8.

With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”?

a)

SELECT * FROM Persons WHERE FirstName=’a’

b)

SELECT * FROM Persons WHERE FirstName LIKE ‘a%’

c)

SELECT * FROM Persons WHERE FirstName LIKE ‘%a’

d)

SELECT * FROM Persons WHERE FirstName=’%a%’

9.

SQL query to find all the cities whose humidity is 95.

a)

SELECT city WHERE humidity = 95

b)

SELECT city FROM weather WHERE humidity = 95

c)

SELECT humidity = 89 FROM weather

d)

SELECT city FROM weather

10.

Find the name of those cities with temperature and condition whose condition is either sunny or cloudy but temperature must be greater than 70.

a)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition = ‘cloudy’ OR temperature > 70

b)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ OR temperature > 70

c)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ OR condition = ‘cloudy’ AND temperature > 70

d)

SELECT city, temperature, condition FROM weather WHERE condition = ‘sunny’ AND condition = ‘cloudy’ AND temperature > 70

11.

DDL means

(a)  

12.

DML

(a)  

13.
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;
14.

Which Symbol means "All"

a)

*

b)

&

c)

%

d)

!

15.

What will be the output?

SELECT ROUND(36.7894,2)

a)

36.78

b)

38.79

c)

36.7

d)

36

16.
What is a special value in SQL that represents missing or unknown data?
a)
%
b)
?
c)
NULL
d)
*
17.
Return 2 movies with that include the word power.
a)
SELECT * FROM movies WHERE name = ‘%power%’ LIMIT 2;
b)
SELECT * FROM movies WHERE genre LIKE ‘%power%’ LIMIT 2;
c)
SELECT * FROM movies WHERE name LIKE ‘%power%’ LIMIT 2;
d)
SELECT * FROM games WHERE name LIKE ‘%power%’ LIMIT 2;
18.
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;
19.
a)
SELECT * FROM movies WHERE genre = 'horror' AND imdb_rating >= 7  LIMIT 8; ORDER BY ASC LIMIT 8;
b)
SELECT * FROM movies WHERE genre = 'horror' AND imdb_rating >= 7  LIMIT 8;
c)
SELECT * FROM movies WHERE imdb_rating >= 7  LIMIT 8;
d)
SELECT * FROM movies WHERE genre = 'horror' AND imdb_rating >= 7;
20.
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
21.
Write the code for the following: Return all movies containing the word iron.
a)
SELECT * FROM i am a beast 1,2,3 WHERE name LIKE ‘%iron%’;
b)
SELECT * FROM movies WHERE name LIKE ‘%iron%’
c)
SELECT * FROM movies WHERE name LIKE ‘%iron%’;
d)
SELECT FROM movies WHERE name LIKE ‘%iron%’;
22.
Which of these groups are in the six common operators?
a)
#=, ^=, $=
b)
=, !=, >=
c)
>^, <>, =+
d)
<+>, >=<, (<)