# Query selecting only 'distinct on' rows

**URL:** <https://community.influxdata.com/t/query-selecting-only-distinct-on-rows/3652>\
**Category:** Systems\
**Tags:** influxdb, collectd, grafana\
**Created:** [January 11, 2018, 8:57pm UTC](https://community.influxdata.com/t/query-selecting-only-distinct-on-rows/3652 "2018-01-11T20:57:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![f1outsourcing](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@f1outsourcing](https://community.influxdata.com/u/f1outsourcing)\
**Post date:** [January 11, 2018, 8:57pm UTC](https://community.influxdata.com/t/query-selecting-only-distinct-on-rows/3652/1 "2018-01-11T20:57:24Z")

</div>

How should I modify this query so it only reports the last/newest samples of an instance. In the current query some instances are listed twice.

SELECT \* FROM “ceph\_value” WHERE “type” = ‘ceph\_bytes’ AND “type\_instance” = ‘Osd.numpg’ AND “value” \> 0 AND time \> now() - 30s ORDER BY time DESC LIMIT 40

```
time host instance type type_instance value
---- ---- -------- ---- ------------- -----
2018-01-10T09:38:27.524637642Z c03 osd.5 ceph_bytes Osd.numpg 155
2018-01-10T09:38:27.518771543Z c03 osd.2 ceph_bytes Osd.numpg 52
2018-01-10T09:38:24.625571475Z c01 osd.0 ceph_bytes Osd.numpg 129
2018-01-10T09:38:24.621389891Z c01 osd.3 ceph_bytes Osd.numpg 51
2018-01-10T09:38:24.215214993Z c02 osd.4 ceph_bytes Osd.numpg 142
2018-01-10T09:38:24.210770483Z c02 osd.1 ceph_bytes Osd.numpg 44
2018-01-10T09:38:17.522840089Z c03 osd.5 ceph_bytes Osd.numpg 155
2018-01-10T09:38:17.517757301Z c03 osd.2 ceph_bytes Osd.numpg 52
2018-01-10T09:38:14.634087585Z c01 osd.7 ceph_bytes Osd.numpg 56
2018-01-10T09:38:14.625388215Z c01 osd.0 ceph_bytes Osd.numpg 129
2018-01-10T09:38:14.621325111Z c01 osd.3 ceph_bytes Osd.numpg 51
2018-01-10T09:38:14.215173666Z c02 osd.4 ceph_bytes Osd.numpg 142
2018-01-10T09:38:14.210634992Z c02 osd.1 ceph_bytes Osd.numpg 44
2018-01-10T09:38:07.523106781Z c03 osd.5 ceph_bytes Osd.numpg 155
2018-01-10T09:38:07.517833556Z c03 osd.2 ceph_bytes Osd.numpg 52
```
