thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

DISTINCT Keyword

A SELECT modifier that removes duplicate rows from the result.

Definition

DISTINCT applies to the entire selected row, not to a single column. COUNT(DISTINCT col) counts unique non-null values. Because DISTINCT requires sorting or hashing, using it to hide duplicate rows produced by a bad join is a code smell.

Example

SELECT COUNT(DISTINCT CustomerID) FROM Orders;

Exam tip

SELECT DISTINCT a, b deduplicates the (a, b) combination, not column a alone.

Related terms