Eliminating duplicate rows from result-set using PostgreSQL

7 sec read

  • Use the DISTINCT ON keyword in your query
  • To do a case-insensitive search do the following query
    SELECT DISTINCT ON(upper(surname)) surname FROM employees ORDER BY upper(surname)
  • This will return non-duplicate surnames.

 

Last Updated On April 07, 2018

Leave a Reply

avatar
  Subscribe  
Notify of