Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PostgreSQL's `DISTINCT ON` extension is useful for navigating bitemporal data in which I want, for example, the latest recorded version of an entry, for each day of the year.

There are few other legitimate use cases of the regular `DISTINCT` that I have seen, other than the typical one-off `SELECT DISTINCT(foo) FROM bar`.



Without DISTINCT ON (which I've never used) you can use a window function via the OVER clause with PARTITION BY. I'm pretty sure that's standard SQL.


Yes, this is the implementation I have seen in other dialects.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: