O'Reilly logo

Tera-Tom's 1000 Page e-Book on Teradata Architecture and SQL, 2nd Edition by Tom Coffing, William Coffing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17 - Distinct Vs. Group By

“All things will be clear and distinct to the man who does not hurry; haste is blind and improvident.”

- Titus Livius

The Distinct Command

images

DISTINCT eliminates duplicates from returning in the Answer Set.

Distinct vs. GROUP BY

images

Distinct and GROUP BY in the two examples return the same answer set.

Rules of Thumb for DISTINCT vs. GROUP BY

images

Rules for Distinct Vs. GROUP BY

(1) Many Duplicates – use GROUP BY (2) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required