Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Simple Queries in SQL

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.

Which of the following attributes can be considered as a choice for a primary key?

a)

Name

b)

Street

c)

RollNo

d)

Subject

2.

What does "SQL" stand for?

a)

Structured Question Language

b)

Structured Query Language

c)

Simple Query Language

d)

Simple Question Language

3.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

4.

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

a)

Where

b)

Order by

c)

From

d)

Select

5.

Less than or equal to?

a)

>=

b)

=>

c)

=<

d)

<=

6.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

7.

How do we select all rows for the "Designer" table?

a)

SELECT * FROM Designer

b)

SELECT [All] FROM Designer

c)

SELECT Designer.*

d)

SELECT FROM Designer

8.

How would we script a SQL query to select "Description" from the Item table?

a)

SELECT Item.Description

b)

EXTRACT Description FROM Item

c)

SELECT Item FROM Description

d)

SELECT Description FROM Item

9.

Which query would return only the fields DesignerID and Designer?

a)

SELECT * FROM Designers

b)

SELECT DesignerID, Name FROM Designers

c)

SELECT DesignerID AND Designer FROM Designers

d)

SELECT DesignerID, Designer FROM Designers

10.

How would you display Chairs in the Items table that have a Price greater than £50.

a)

SELECT * FROM Items WHERE Type = 'Chair' AND Price > 50

b)

SELECT * FROM Items WHERE Type = 'Chair' OR Price < 100

c)

SELECT * FROM Iterms WHERE Type = 'Chair' AND Price >= 50

d)

SELECT * FROM Items WHERE Price > 50

11.

Match the following SQL term with a description - ORDER BY

a)

The fields to display

b)

The field and order used to sort the results

c)

The table used in the query

d)

The criteria that must be met

12.

Which symbol would you use to represent more than 50

a)

= 50

b)

< 50

c)

> 50

d)

# 50

13.

When examining a row in a table, we refer to it as a...

a)

row number

b)

result number

c)

record

d)

result

14.

When examining a column in a table, we refer to it as a...

a)

field name

b)

folder name

c)

column number

d)

table name

15.

What would the SQL query pictured do?

a)

Find all the men

b)

Find all of the female writers

c)

Find all of Elgar's friends

d)

Find all the male writers

e)

Find all the fish

16.
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
17.

The language used application programs to request data from the DBMS is referred to as __________

a)

DDL

b)

DML

c)

Query Language

d)

All of the mentioned

18.

Which of the following is not a type of SQL statement?

a)

Data Manipulation Language (DML)

b)

Data Definition Language (DDL)

c)

Data Control Language (DCL)

d)

Data Communication Language (DCL)

19.

DDL Stands for ___________.

a)

Data Management Language

b)

Data Manupulation Language

c)

Data Development Language

d)

Data Definition Language

20.

Which SQL function is used to find the average value of any column?

a)

Mean()

b)

Avg()

c)

Average()

d)

Sum()

21.

Which would show all fields from the Pupils table?

a)

SELECT * FROM Pupils

b)

SELECT Name, Form FROM Pupils

c)

SELECT * FROM *

d)

SELECT * FROM Forms

22.

Which Symbol means "All"

a)

*

b)

&

c)

%

d)

!

23.

Which would find pupils with "er" anywhere in their name?

a)

SELECT * FROM Pupils Where Name = "%er"

b)

SELECT * FROM Pupils Where Name = "$er$"

c)

SELECT * FROM Pupils Where Name = "%er%"

d)

SELECT * FROM Pupils Where Name = "er%"

24.

Choose the correct query

a)

SELECT * FROM EMP WHERE NAME=NULL

b)

SELECT * FROM EMP WHERE NAME IS NULL;

c)

SELECT FROM EMP WHERE NAME IS NULL;

d)

SELECT *FROM EMP WHERE NAME IS 'NULL';

25.

Which is not an aggregate function?

a)

SUM()

b)

POW()

c)

AVG()

d)

COUNT()

26.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (*) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

27.

Consider the following SQL statement. What type of statement is this? SELECT * FROM Employee;

a)

DML

b)

DDL

c)

DCL

d)

TCL

28.

Which of the following query contains error?

a)

SELECT * FROM Emp WHERE Empid=1001;

b)

SELECT Empid FROM Emp WHERE Empid=1001;

c)

SELECT Empid FROM Emp;

d)

SELECT Empid WHERE empid=1001;

29.

Which operator performs pattern matching?

a)

BETWEEN

b)

LIKE

c)

EXISTS

d)

None of These

30.

The pattern '_ _ _' matches any string of ______ three characters, '_ _ _ %' matches any string of ________ three characters.

a)

At least, Exactly

b)

Exactly, At least

c)

At least, All

d)

All, Exactly