Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. country | landscape | household
  2. --------------------------------
  3. TZA | L01 | HH02
  4. TZA | L01 | HH03
  5. KEN | L02 | HH01
  6. RWA | L03 | HH01
  7.  
  8. SELECT country,
  9. landscape,
  10. household,
  11. flag_duplicates(country, landscape) AS flag
  12. FROM mytable
  13.  
  14. country | landscape | household | flag
  15. ---------------------------------------
  16. TZA | L01 | HH02 | duplicated
  17. TZA | L01 | HH03 | duplicated
  18. KEN | L02 | HH01 |
  19. RWA | L03 | HH01 |
  20.  
  21. IF (country || landscape IN (SELECT country || landscape FROM mytable
  22. GROUP BY country || landscape)
  23. HAVING count(*) > 1) THEN 'duplicated'
  24. ELSE NULL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement