Nick The Greek
Nick The Greek

Reputation: 453

How to query location every 15 mins?

I have a QuestDB table with item locations similar to the taxi trip database on the QuestDB Live demo and I want to query location but no more than every X mins per item. Similar query on the demo server would be

SELECT vendor_id, pickup_latitude, pickup_longitude 
FROM trips 
WHERE vendor_id = 'VTS' 
SAMPLE BY 15m

but get back error

at least one aggregation function must be present in 'select' clause

I don't want any aggregation like average etc, I just need the location every hour (or X mins). Is there a way to query that?

Upvotes: 1

Views: 138

Answers (1)

Alex des Pelagos
Alex des Pelagos

Reputation: 1485

Use first for aggregation

SELECT vendor_id, first(pickup_latitude) lat, first(pickup_longitude) Lon
FROM trips 
WHERE vendor_id = 'VTS' 
SAMPLE BY 15m

Upvotes: 0

Related Questions