Eliminating duplicate rows from result-set using PostgreSQL

Written by Ian Carnaghan · 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
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. Profile

Leave a Reply

Notify of