Font size
Worksheetssql
Total questions: 44
Worksheet time: 27mins
What does "SQL" stand for?
Structured Question Language
Structured Query Language
Simple Query Language
Simple Question Language
Which statement is used to extract data from a database?
Extract
Get
Open
Select
If you were wanting to filter data, which clause would you use?
Where
Order by
From
Select
Using which word allows you to specify that more than one condition must be met in a query?
Also
And
Or
Where
Using which word allows you to specify that only one of a series of conditions needs to be met in a query filter?
And
Maybe
If
Or
To remove a record from a table which SQL statement would you use?
Remove
Cancel
Delete
Eradicate
Which statement allows us to add a record to a table?
Add To
Update To
Add Into
Insert Into
Which character returns all the data found in a table?
%
#
*
/
Which word is missing from the following SQL statement?
Select * table_name
With
Where
From
And
What is the correct order of clauses in a SQL statement?
SELECT, FROM, ORDER BY, WHERE
SELECT, FROM, WHERE, ORDER BY
SELECT, WHERE, FROM, ORDER BY
WHERE, FROM, SELECT, ORDER BY
How do we select all rows for the "Designer" table?
SELECT * FROM Designer
SELECT [All] FROM Designer
SELECT Designer.*
SELECT FROM Designer
How would we script a SQL query to select "Description" from the Item table?
SELECT Item.Description
EXTRACT Description FROM Item
SELECT Item FROM Description
SELECT Description FROM Item
You are required to update the phone number for only the DesignerID "SMI01" in the "Designer" table. Which of these would successfully do that?
UPDATE Designer SET PhoneNo = '01224123456'
UPDATE Designer (PhoneNo) VALUES ('01224123456')
UPDATE Designer SET PhoneNo = '01224123456' WHERE DesignerID = 'SMI01'
UPDATE PhoneNo = '01224123456' FROM Designer WHERE DesignerID = 'SMI01'
With SQL how can I return all items in the Item table sorted from the lowest priced to the highest priced?
SELECT * FROM Items ORDER BY Price ASCENDING
SELECT * FROM Items ORDER BY Price ASC
SELECT * FROM Items BY Price LOWEST TO HIGHEST
SELECT * FROM Items ORDER BY Price DESC
How would you DELETE records from the Items table with a "Chair" Type?
DELETE 'Chair' FROM Items
DELETE Type FROM Items WHERE Type = 'Chair'
DELETE FROM Items WHERE Type = 'Chair'
DELETE ITEMS WHERE Type = 'Chair'
How would you display Chairs in the Items table that have a Price greater than £50.
SELECT * FROM Items WHERE Type = 'Chair' AND Price > 50
SELECT * FROM Items WHERE Type = 'Chair' OR Price < 100
SELECT * FROM Iterms WHERE Type = 'Chair' AND Price >= 50
SELECT * FROM Items WHERE Price > 50
Match the following SQL term with a description - FROM
The criteria which must be met
The fields to display
The field and order used to sort the results
The table used in the query
Match the following SQL term with a description - SELECT
The fields to display
The table used in the query
The criteria which must be met
The field and order used to sort the results
Match the following SQL term with a description - WHERE
The table used in the query
The fields to display
The field and order used to sort the results
The criteria which must be set
Match the following SQL term with a description - ORDER BY
The fields to display
The field and order used to sort the results
The table used in the query
The criteria that must be met
This symbol is an SQL wildcard that can substitute for one or more characters when searching for data in a database.
$
%
=
*
Quali tra le seguenti condizioni di ricerca sono corrette ?
Codice BETWEEN 1 AND 10
Codice IN (1,2,3,4,5,6,7,8,9,10)
Codice BETWEEN 10 AND 1
DataNascita LIKE 01/01/2003
Quali tra le seguenti sono funzioni di aggregazione ?
COUNT
EXIST
IN
MAX
Quali tra le seguenti sono funzioni di aggregazione ?
AVG
ALL
SUM
ANY
Quali tra le seguenti affermazioni sono vere?
La clausola GROUP BY viene inserita per ordinare i dati in base ai valori contenuti in una o più colonne
La clausola ORDER BY viene inserita per ordinare i dati in base ai valori contenuti in una o più colonne
La clausola HAVING può essere usata solo con la clausola GROUP BY
SELECT *
_______ CUSTOMER;
SQL table names are case sensitive
FROM PRODUCT
will return how many rows?
Per ottenere i dati dei film usciti dopo il 2010
SELECT id, name, year FROM movies WHERE year > 2010;
SELECT id, name, year FROM movies WHERE year < 2010;
SELECT * FROM movies WHERE year > 2010;
SELECT id, name, year FROM movies WHERE YEAR > 2010;
Tutti i drammi usciti dopo il 2004.
SELECT * FROM movies WHERE genere = 'dramma';
SELECT * FROM movies WHERE genere = "dramma" AND year > 2004;
SELECT * FROM movies WHERE genere = <dramma> AND year < 2004;
SELECT * FROM movies WHERE rating = 7 AND LIMIT = 7
Ritorna il nome ed il genere di ogni film con un rating > 5 e anno uscita dopo il 2012.
SELECT * FROM movies WHERE rating > 5 AND year > 2012;
SELECT name, genere FROM movies WHERE rating < 5 AND year < 2012;
SELECT name, year FROM movies WHERE rating > 5 year > 2012;
SELECT name, genere FROM movies WHERE rating > 5 AND year > 2012;
la sintassi per creare una tabella è...
CREATE TABLE <table name> (field_name DATATYPE ... );
TABLE <table name> (field_name DATATYPE);
CREATE <table name> ( DATATYPE field_name);
SELECT <fieldname> FROM <table name)
la funzione di aggregazione per trovare il valore più piccolo è ...
COUNT
MAX
MIN
AVG
Query
È lo strumento per estrarre i dati secondo i criteri scelti dall’utente
Rappresenta una Interrogazione che si può chiedere al DB
Il formato più semplice è SELECT * FROM <Nome Tabella>
Fammi vedere la Materia che insegna il professore "Ionta"
tradotta in SQL diventa
Select Materia From Docenti Where Cognome='Ionta'
Select Materia From Docenti Where Nome='Ionta'
Select Materie From Docente Where Cognome='Ionta'
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"
Vero
Falso
Select Nomi, Classe
From Alunni
Where Classe in (Select Classe
From Alunni
Group By Classe
Having Count(*) <10);
Ritorna i nomi con le loro classi degli alunni che sono in classi poco numerose (<10 alunni)
Ritorna i nomi degli alunni che sono in classi con pochi alunni (<10)
Ritorna i nomi con le loro classi degli alunni che sono in classi numerose
Ritorna le classi che hanno pochi alunni (<10)
Select Alunni, AVG(Voto)
From Alunni
Where AVG(Voto) >= 6
And Classe = "4B";
Ritorna gli alunni promossi della "4B"
Ritorna gli alunni rimandati della "4B"
Ritorna gli alunni Bocciatidella "4B"
Select Alunni, Voto
From Alunni
Where
Classe = "4A"
And
Voto < (Select Avg (Voto)
From Alunni
Group By Classe
Having Classe ="4A";)
Seleziona i peggiori alunni della 4A
Seleziona gli alunni della 4A con voto inferiore alla media della classe
Seleziona i più bravi della classe "4A"
Seleziona gli alunni della "4A" che hanno voti inferiori alla media della "4B"
Select Valore2
From Dati
Where Valore1 In (Select Valore1
From Dati
Where Valore1>100);
Selziona dalla Tabella Dati i valori della seconda colonna che hanno i corrispondenti valori della prima > 100
Selziona dalla Tabella Dati i valori della prima colonna che hanno i corrispondenti valori della seconda > 100
Selziona dalla Tabella Dati valori della seconda colonna che sono > 100
meglio la forma ridotta
Select Valore2
From Dati
Where Valore1 >100;
