Home Databases pgSql Elimiating duplicate rows from result-set using Postgres
 
 
 

Elimiating duplicate rows from result-set using Postgres

PDF Print E-mail

Question: How to remove duplicate rows in a result-set returned from a SELECT query using Postgres?

 

Answer:

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



+/-
+/- Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
Security Please input the anti-spam code that you can read in the image.
 

Go Daddy $7.49 .com Sale!