wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

sql

Total questions: 44

Worksheet time: 27mins

Name
Class
Date
1.

What does "SQL" stand for?

a)

Structured Question Language

b)

Structured Query Language

c)

Simple Query Language

d)

Simple Question Language

2.

Which statement is used to extract data from a database?

a)

Extract

b)

Get

c)

Open

d)

Select

3.

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

a)

Where

b)

Order by

c)

From

d)

Select

4.

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

5.

Using which word allows you to specify that only one of a series of conditions needs to be met in a query filter?

a)

And

b)

Maybe

c)

If

d)

Or

6.

To remove a record from a table which SQL statement would you use?

a)

Remove

b)

Cancel

c)

Delete

d)

Eradicate

7.

Which statement allows us to add a record to a table?

a)

Add To

b)

Update To

c)

Add Into

d)

Insert Into

8.

Which character returns all the data found in a table?

a)

%

b)

#

c)

*

d)

/

9.

Which word is missing from the following SQL statement?


Select * table_name

a)

With

b)

Where

c)

From

d)

And

10.

What is the correct order of clauses in a SQL statement?

a)

SELECT, FROM, ORDER BY, WHERE

b)

SELECT, FROM, WHERE, ORDER BY

c)

SELECT, WHERE, FROM, ORDER BY

d)

WHERE, FROM, SELECT, ORDER BY

11.

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

12.

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

13.

You are required to update the phone number for only the DesignerID "SMI01" in the "Designer" table. Which of these would successfully do that?

a)

UPDATE Designer SET PhoneNo = '01224123456'

b)

UPDATE Designer (PhoneNo) VALUES ('01224123456')

c)

UPDATE Designer SET PhoneNo = '01224123456' WHERE DesignerID = 'SMI01'

d)

UPDATE PhoneNo = '01224123456' FROM Designer WHERE DesignerID = 'SMI01'

14.

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

15.

How would you DELETE records from the Items table with a "Chair" Type?

a)

DELETE 'Chair' FROM Items

b)

DELETE Type FROM Items WHERE Type = 'Chair'

c)

DELETE FROM Items WHERE Type = 'Chair'

d)

DELETE ITEMS WHERE Type = 'Chair'

16.

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

17.

Match the following SQL term with a description - FROM

a)

The criteria which must be met

b)

The fields to display

c)

The field and order used to sort the results

d)

The table used in the query

18.

Match the following SQL term with a description - SELECT

a)

The fields to display

b)

The table used in the query

c)

The criteria which must be met

d)

The field and order used to sort the results

19.

Match the following SQL term with a description - WHERE

a)

The table used in the query

b)

The fields to display

c)

The field and order used to sort the results

d)

The criteria which must be set

20.

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

21.

This symbol is an SQL wildcard that can substitute for one or more characters when searching for data in a database.

a)

$

b)

%

c)

=

d)

*

22.
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;
23.
Write a code for the following: Return the names and imdb_ratings of all movies with ‘day’ in the name.
a)
SELECT * FROM movies WHERE name LIKE ‘day’;
b)
RETURN  name, imdb_rating FROM movies WHERE name LIKE '%day%';
c)
SELECT name, imdb_rating FROM movies WHERE name LIKE '%day%';
d)
SELECT * FROM movies WHERE imdb_rating AND name LIKE ‘%day%’;
24.

Quali tra le seguenti condizioni di ricerca sono corrette ?

a)

Codice BETWEEN 1 AND 10

b)

Codice IN (1,2,3,4,5,6,7,8,9,10)

c)

Codice BETWEEN 10 AND 1

d)

DataNascita LIKE 01/01/2003

25.

Quali tra le seguenti sono funzioni di aggregazione ?

a)

COUNT

b)

EXIST

c)

IN

d)

MAX

26.

Quali tra le seguenti sono funzioni di aggregazione ?

a)

AVG

b)

ALL

c)

SUM

d)

ANY

27.

Quali tra le seguenti affermazioni sono vere?

a)

La clausola GROUP BY viene inserita per ordinare i dati in base ai valori contenuti in una o più colonne

b)

La clausola ORDER BY viene inserita per ordinare i dati in base ai valori contenuti in una o più colonne

c)

La clausola HAVING può essere usata solo con la clausola GROUP BY

28.
What word is missing from the line below?
SELECT *
_______ CUSTOMER;
a)
FROM
b)
WHERE
c)
SELECT
d)
ORDER BY
29.
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"
30.
True/False?
SQL table names are case sensitive
a)
True
b)
False
31.
What represents no value? 
a)
NULL
b)
" "
c)
0
d)
N/A
32.
SELECT MAX(price)
FROM    PRODUCT
will return how many rows?
a)
1
b)
0
c)
2
d)
As many rows that are in the table
33.

Per ottenere i dati dei film usciti dopo il 2010

a)

SELECT id, name, year FROM movies WHERE year > 2010;

b)

SELECT id, name, year FROM movies WHERE year < 2010;

c)

SELECT * FROM movies WHERE year > 2010;

d)

SELECT id, name, year FROM movies WHERE YEAR > 2010;

34.

Tutti i drammi usciti dopo il 2004.

a)

SELECT * FROM movies WHERE genere = 'dramma';

b)

SELECT * FROM movies WHERE genere = "dramma" AND year > 2004;

c)

SELECT * FROM movies WHERE genere = <dramma> AND year < 2004;

d)

SELECT * FROM movies WHERE rating = 7 AND LIMIT = 7

35.

Ritorna il nome ed il genere di ogni film con un rating > 5 e anno uscita dopo il 2012.

a)

SELECT * FROM movies WHERE rating > 5 AND year > 2012;

b)

SELECT name, genere FROM movies WHERE rating < 5 AND year < 2012;

c)

SELECT name, year FROM movies WHERE rating > 5 year > 2012;

d)

SELECT name, genere FROM movies WHERE rating > 5 AND year > 2012;

36.

la sintassi per creare una tabella è...

a)

CREATE TABLE <table name> (field_name DATATYPE ... );

b)

TABLE <table name> (field_name DATATYPE);

c)

CREATE <table name> ( DATATYPE field_name);

d)

SELECT <fieldname> FROM <table name)

37.

la funzione di aggregazione per trovare il valore più piccolo è ...

a)

COUNT

b)

MAX

c)

MIN

d)

AVG

38.

Query

a)

È lo strumento per estrarre i dati secondo i criteri scelti dall’utente

b)

Rappresenta una Interrogazione che si può chiedere al DB

c)

Il formato più semplice è SELECT * FROM <Nome Tabella>

39.

Fammi vedere la Materia che insegna il professore "Ionta"

tradotta in SQL diventa

a)

Select Materia From Docenti Where Cognome='Ionta'

b)

Select Materia From Docenti Where Nome='Ionta'

c)

Select Materie From Docente Where Cognome='Ionta'

40.

Select Nome

From Alunni

Where Voto > (select Max(Voto)

From Alunni

Group By Classe

Having Classe ="4A");


Seleziona i nomi degli alunni della scuola che sono più bravi degli alunni della "4A"

a)

Vero

b)

Falso

41.

Select Nomi, Classe

From Alunni

Where Classe in (Select Classe

From Alunni

Group By Classe

Having Count(*) <10);

a)

Ritorna i nomi con le loro classi degli alunni che sono in classi poco numerose (<10 alunni)

b)

Ritorna i nomi degli alunni che sono in classi con pochi alunni (<10)

c)

Ritorna i nomi con le loro classi degli alunni che sono in classi numerose

d)

Ritorna le classi che hanno pochi alunni (<10)

42.

Select Alunni, AVG(Voto)

From Alunni

Where AVG(Voto) >= 6

And Classe = "4B";

a)

Ritorna gli alunni promossi della "4B"

b)

Ritorna gli alunni rimandati della "4B"

c)

Ritorna gli alunni Bocciatidella "4B"

43.

Select Alunni, Voto

From Alunni

Where

Classe = "4A"

And

Voto < (Select Avg (Voto)

From Alunni

Group By Classe

Having Classe ="4A";)

a)

Seleziona i peggiori alunni della 4A

b)

Seleziona gli alunni della 4A con voto inferiore alla media della classe

c)

Seleziona i più bravi della classe "4A"

d)

Seleziona gli alunni della "4A" che hanno voti inferiori alla media della "4B"

44.

Select Valore2

From Dati

Where Valore1 In (Select Valore1

From Dati

Where Valore1>100);

a)

Selziona dalla Tabella Dati i valori della seconda colonna che hanno i corrispondenti valori della prima > 100

b)

Selziona dalla Tabella Dati i valori della prima colonna che hanno i corrispondenti valori della seconda > 100

c)

Selziona dalla Tabella Dati valori della seconda colonna che sono > 100

d)

meglio la forma ridotta

Select Valore2

From Dati

Where Valore1 >100;