SQL Practicals Flashcards

1
Q

Get all the columns from the Customers table.

A

SELECT * FROM Customers;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write a statement that will select the City column from the Customers table.

A

SELECT City FROM Customers;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Select all the different values from the Country column in the Customers table.

A

SELECT DISTINCT Country FROM Customers;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Select all the columns from the Customers table, then

Select all records where the City column has the value “Berlin”.

A

SELECT * FROM Customers WHERE City = ‘Berlin’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Select all the columns from the Customers table, then

use the NOT keyword to select all records where City is NOT “Berlin”

A

SELECT * FROM Customers WHERE NOT City = ‘Berlin’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Select all the columns from the Customers table, then select all records where the CustomerID column has the value 32.

A

SELECT * FROM Customers WHERE CustomerID = 32;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Select all the columns from the Customers table, then select all records where the City column has the value ‘Berlin’ AND the PostalCode column has the value 12209.

A

SELECT * FROM Customers WHERE City = ‘Berlin’ AND PostalCode = 12209;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Select all the columns from the Customers table, then select all records where the City column has the value ‘Berlin’ or ‘London’.

A

SELECT * FROM Customers WHERE City = ‘Berlin’ OR City = ‘London’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Select all the columns from the Customers table, then sort the result alphabetically by the column City.

A

SELECT * FROM Customers ORDER BY City;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Select all the columns from the Customers table, then sort the result reversed alphabetically by the column City.

A

SELECT * FROM Customers ORDER BY City DESC;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Select all the columns from the Customers table, then sort the results alphabetically, first by column Country, then, by the column City.

A

SELECT * FROM Customers ORDER BY Country, City;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Insert a new record in the Customers table which includes CustomerName, Address, City, PostalCode, Country with the corresponding values of John Smith, 15 Wilson St, Detroit, 33303, USA.

A

INSERT INTO Customers ( CustomerName, Address, City, PostalCode, Country) VALUES ( John Smith, 15 Wilson St, Detroit, 33303, USA);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Select all the columns from the Customers table where the PostalCode column is empty.

A

SELECT * FROM Customers WHERE PostalCode IS NULL;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Select all the columns from the Customers table where the PostalCode is not empty.

A

SELECT * FROM Customers WHERE PostalCode IS NOT NULL;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Update the City column of all records in the Customers table with the City ‘Oslo’.

A

UPDATE Customers SET City = ‘Oslo’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Update the City column in the Customers table to ‘Oslo’, but only the ones where the Country column has the value ‘Norway’

A

UPDATE Customers SET City = ‘Oslo’ WHERE Country = ‘Norway’;

17
Q

Update the City value and the Country value in the Customers table for all CustomerID that equal 32.

A

UPDATE Customers SET City = ‘Oslo’, Country = ‘Norway’ WHERE CustomerID = 32;