W3. SQL Select Distinct Flashcards

1
Q

Q: What does the SQL SELECT DISTINCT statement do?

A

A: It returns only distinct (unique) values from a specified column.

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

Q: Write an SQL query to select all distinct countries from the “Customers” table.

A

A: SELECT DISTINCT Country FROM Customers;

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

Q: Why might you use the SELECT DISTINCT statement?

A

A: To list only the different (unique) values in a column that may contain duplicates.

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

Q: What is the general syntax for the SELECT DISTINCT statement?

A

A: SELECT DISTINCT column1, column2, … FROM table_name;

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

Q: What happens if you omit DISTINCT in a SELECT statement?

A

A: The query will return all values, including duplicates, from the specified column(s).

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

Q: How can you count the number of distinct values in a column?

A

A: Use COUNT(DISTINCT column_name) in your query, e.g.,
SELECT COUNT(DISTINCT Country) FROM Customers;

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

Q: Is COUNT(DISTINCT column_name) supported in Microsoft Access?

A

A: No, Microsoft Access does not support COUNT(DISTINCT column_name) directly.

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

Q: How can you work around the lack of COUNT(DISTINCT column_name) support in MS Access?

A

A: Use a subquery: SELECT Count(*) AS DistinctCountries FROM (SELECT DISTINCT Country FROM Customers);

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