Check out example codes for "sql server select rows by distinct column". It will help you in understanding the concepts better.

Code Example 1

SELECT a.*
FROM emails a
INNER JOIN 
  (SELECT email,
    MIN(id) as id
  FROM emails 
  GROUP BY email 
) AS b
  ON a.email = b.email 
  AND a.id = b.id;

Learn ReactJs, React Native from akashmittal.com