How do you select multiple columns from a table while ensuring that one specific column doesn't contain duplicate values?
SELECT DISTINCT col1,col2,col3,col4 from table
This doesn't work, because DISTINCT here applies to all columns so columns as a whole are distinct. But I want a single column to have distinct values.
Question
Code149
How do you select multiple columns from a table while ensuring that one specific column doesn't contain duplicate values?
This doesn't work, because DISTINCT here applies to all columns so columns as a whole are distinct. But I want a single column to have distinct values.
I'm using SQL Server. :)
Link to comment
https://www.neowin.net/forum/topic/974024-sql-select-multiple-columns-with-only-one-distinct-column/Share on other sites
6 answers to this question
Recommended Posts