Eliminating duplicate rows from result-set using PostgreSQL
- 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.
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