DISTINCT

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/8

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:30 PM on 9/30/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

9 Terms

1
New cards

DISTINCT

Removes duplicate rows from a query result. Example: SELECT DISTINCT major returns each major once.

2
New cards

SELECT DISTINCT syntax

SELECT DISTINCT column_name FROM table_name;

3
New cards

DISTINCT example

SELECT DISTINCT academic_year FROM Students_Spring2024; Returns Freshman, Sophomore, Junior, and Senior once each.

4
New cards

DISTINCT with two columns

Returns unique combinations of all selected fields. Example: SELECT DISTINCT academic_year, major FROM Students_Spring2024;

5
New cards

DISTINCT and multiple columns

If either selected value differs, the row stays. Example: Freshman + Finance and Freshman + Marketing are different rows.

6
New cards

COUNT(DISTINCT column)

Counts unique non-NULL values. Example: SELECT COUNT(DISTINCT major) AS NumMajors FROM Students_Fall2024;

7
New cards

COUNT without DISTINCT

Counts every non-NULL value, including repeats. Example: COUNT(major) counts every student’s major entry.

8
New cards

DISTINCT vs. UNION

DISTINCT removes duplicates within one query result; UNION combines two query results and removes duplicate rows.

9
New cards

When not to use DISTINCT

Do not use it just to hide a bad JOIN; first make sure the JOIN conditions are correct.