Eliminating duplicate rows from result-set using PostgreSQL

E
  • 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.

 

About the author

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.

About Author

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.

Follow Me