SQL Flashcards
Coding for Databases
1
Q
What statement would you use to return the “Country” value from all the records of the “Customers” table?
A
SELECT Country FROM Customers;
2
Q
What statement would you use to return the number of different countries?
A
SELECT Count(*) AS DistinctCountries FROM (SELECT DISTINCT Country FROM Customers);
Count Distinct
3
Q
What is the Count Distinct Format
A
COUNT(DISTINCT column_name)
-
DISTINCT
is a keyword in a function -
COUNT
is a function
4
Q
Which SQL statements would return a list of all unique countries from a table named Customers
?
A
SELECT DISTINCT Country
FROM Customers;
5
Q
What would be the result of omitting the DISTINCT
keyword in a statement like SELECT DISTINCT Country FROM Customers;
?
A
It would return all values, including duplicates, in the Country
column
6
Q
A