Influxdb annotations, filter duplicates

I have a influxdb measurement that displays a temperature series. The measurements are inserted from mqtt by telegraf.

The measurement also contains the name of the process-step as a field, and I would like to display the start of the process-step as annotations. But if i just pull the values from the measurement I’ll en up with thousands of annotation in the graph, one for each data point.

How can I filter out duplicate annotations when they occur together and only display the first occurrence?

In SQL I would probably use something like:
select id, c1 from @tbl t1 where c1 <> (select top 1 c1 from @tbl t2 where t2.id < t1.id order by id desc)
(with a proper where clause and a union to get the first row)