T-SQL 101: 18 - Removing duplicate rows by using DISTINCT
If I query rows from a SQL Server table, I don’t always want all the rows returned. In particular, I might not want any duplicates. I can remove them by using DISTINCT.
Here’s a simple example. I want a list of the sizes that products can come in, so I execute this query:
Note that although I get a list of sizes, I get a row returned for every row in the table. If I add DISTINCT to the query, look at the effect that it has:
2019-05-20