Results for “DISTINCT”
Small, practical examples. Search by task or narrow things down below.
Get the latest row in each group
Select one ordered row per key with DISTINCT ON.
DISTINCT ON✓ Tested
Remove duplicate records by a selected key
C#: DistinctBy keeps the first record for each key in encounter order.
C#✓ Tested
Remove duplicate result values
SQL: Use DISTINCT when repeated category values are not useful.
SQL✓ Tested
Remove duplicate result values
SQL Server: Use DISTINCT when repeated category values are not useful.
SQL Server✓ Tested
Remove duplicate result values
Postgres: Use DISTINCT when repeated category values are not useful.
Postgres✓ Tested
Remove duplicate result values
SQLite: Use DISTINCT when repeated category values are not useful.
SQLite✓ Tested
Remove duplicate values
Use LINQ Distinct and OrderBy for a sorted C# result.
C#✓ Tested
Remove duplicate values
Preserve encounter order while removing repeated Java list values.
Java✓ Tested
Remove duplicate values
Use a JavaScript Set to preserve the first occurrence of each primitive value.
JavaScript✓ Tested
Sort and deduplicate values
Sort a C++ vector and erase adjacent duplicates.
C++✓ Tested
Capture standard output and standard error separately
Bash Scripts: Use distinct redirections when diagnostic text should not be mixed with data.
Bash Scripts✓ Tested
Find rows in the first result but not the second
SQL: EXCEPT calculates a distinct result-set difference.
SQL✓ Tested