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?

Table Customer
A
SELECT Country FROM Customers;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What statement would you use to return the number of different countries?

Table Customer
A
SELECT Count(*) AS DistinctCountries
FROM (SELECT DISTINCT Country FROM Customers);

Count Distinct

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

What is the Count Distinct Format

A
COUNT(DISTINCT column_name)
  • DISTINCT is a keyword in a function
  • COUNT is a function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which SQL statements would return a list of all unique countries from a table named Customers?

A

SELECT DISTINCT Country

FROM Customers;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

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