SELECT ALL DISTINCT ON ( col_ref , ) target_elem , FROM table_expr , join_expr WHERE expr GROUP BY col_ref , OPTIONS ( option = val , ) HAVING expr ORDER BY col_ref ASC DESC NULLS LAST NULLS FIRST , LIMIT expr OFFSET integer UNION INTERSECT EXCEPT ALL DISTINCT another_select_stmt