Use this tag for questions relevant to DISTINCT ON, which is used to eliminate rows that match on all specified expressions.
I want to run this query: SELECT DISTINCT ON (address_id) purchases.address_id, purchases.* FROM purchases WHERE purchases.product_…
sql postgresql sql-order-by distinct-onIn PostgreSQL i want to fetch every users at once and order them by date. This is my query: SELECT …
postgresql group-by distinct distinct-onI understand how DISTINCT works, but I don't understand DISTINCT ON (expression). Take the first example from this screenshot: How …
sql database postgresql mod distinct-onFor the following query I need to select only the first record with the lowest shape_type value (ranges from 1 …
sql postgresql distinct greatest-n-per-group distinct-onI have a rails app: user has_many :projects user has_many :tasks, :through => :projects project has_many :tasks …
ruby-on-rails-3 activerecord sql-order-by distinct-onRelated to - PostgreSQL DISTINCT ON with different ORDER BY I have table purchases (product_id, purchased_at, address_id) …
postgresql greatest-n-per-group distinct-on