select_distinct_on.sql 584 B

12345678910111213141516171819
  1. --
  2. -- SELECT_DISTINCT_ON
  3. --
  4. SELECT DISTINCT ON (string4) string4, two, ten
  5. FROM tmp
  6. ORDER BY string4 using <, two using >, ten using <;
  7. -- this will fail due to conflict of ordering requirements
  8. SELECT DISTINCT ON (string4, ten) string4, two, ten
  9. FROM tmp
  10. ORDER BY string4 using <, two using <, ten using <;
  11. SELECT DISTINCT ON (string4, ten) string4, ten, two
  12. FROM tmp
  13. ORDER BY string4 using <, ten using >, two using <;
  14. -- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses
  15. select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2;