Skip to Content

OData Query: How to skip every second entry?

Apr 26 at 01:53 PM


avatar image

I have a small webapp consuming an OData service (in particular the Message Management Service API of SAP Cloud Platform Internet of Things Service). I want to add a query option to my query to skip (e.g.) every second entry. Is that possible with OData options and how? Is there another solution? Filtering the data after downloading would be very unsatisfying. Maybe this may help: The queried data is sort by a timestamp but the duration between to data entries (difference in the timestamp) may vary. So a simple filter by divisibility of the timestamp is not possible.

Thanks in advance!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ralf Handl
Apr 27 at 12:33 PM

Interesting, why do you want to get only the odd entries?

If your entries had a sequence number starting at zero you could use $filter=seqno mod 2 eq 0 to get the "even" ones and $filter=seqno mod 2 eq 1 to get the "odd" ones.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

It was just an example. The OData service provides measurements. The customer can decide the time interval of the queried data. To shorten the data in cases of long time intervals I was thinking about sorting out every second (or third, or fourth) entry. But I found no way to do this.

Unfortunately, there is no sequence number inside the entries.


For "condensing" or "compressing" time series of measurements there's the "M4" algorithm described in and implemented e.g. in IoT "Thing" services, see

This nifty algorithm returns the "most important" subset of a time series given the time interval you are interested in and the "number of pixels" you want to plot.

However, this is a rather special kind of query and not part of the OData standard, so I've no idea whether the Message Management Service API supports this.