# Support "distinct on" grammar

**URL:** <https://community.dremio.com/t/support-distinct-on-grammar/11119>\
**Category:** Uncategorized\
**Created:** [October 27, 2023, 10:27am UTC](https://community.dremio.com/t/support-distinct-on-grammar/11119 "2023-10-27T10:27:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![colagy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/colagy/32/5217_2.png) [@colagy](https://community.dremio.com/u/colagy)\
**Post date:** [October 27, 2023, 10:27am UTC](https://community.dremio.com/t/support-distinct-on-grammar/11119/1 "2023-10-27T10:27:22Z")

</div>

postgres=# select distinct on(course)id,name,course,score from student;

It is already supported on postgreSQL, but not worked in dremio.

---

<div class="post-metadata">

**Author:** ![bogdan.coman](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bogdan.coman](https://community.dremio.com/u/bogdan.coman)\
**Post date:** [November 1, 2023, 4:34am UTC](https://community.dremio.com/t/support-distinct-on-grammar/11119/2 "2023-11-01T04:34:56Z")

</div>

Hi Colagy,

The grammar itself is not implemented in Dremio, but you can [partition data](https://docs.dremio.com/current/sonar/data-sources/entity-promotion/#partitioned-data) in Dremio, then run _SELECT DISTINCT A FROM TABLE – A is partition column_. That grammar looks to be specific to PostgresSQL. The way data warehouses generally go about that is by using [Window Functions](https://www.dremio.com/wiki/window-functions) to divide the dataset into partitions, then analyze the partitions. As a select example please see the “Query a table and filter the result using QUALIFY with window functions in the SELECT list” query [here](https://docs.dremio.com/current/reference/sql/commands/SELECT-statements#examples).

Bogdan
