Steps: Use this Query
SELECT * FROM (SELECT col1,col2, col3,col4, ROW_NUMBER() OVER (PARTITION BY
(write here Distinct col name without brackets) ORDER BY col1) AS RowNumber
FROM TableName) AS a WHERE a.RowNumber = 1"
e.g.
SELECT * FROM (SELECT col1,col2, col3,col4, ROW_NUMBER() OVER (PARTITION BY col1 ORDER BY col1) AS RowNumber FROM TableName) AS a WHERE a.RowNumber = 1"
Here Row_Number() :
Returns the sequential number of a row within a partition of a result set,
starting at 1 for the first row in each partition.

Join the conversation! Your thoughts help the community grow.