Click to copy
Streams • Reviewed for ksqlDB 0.29
How to Query a Stream in ksqlDB
This is an example of a query in ksqlDB:
-- Where are Florida folks traveling to?
SELECT flight_id, to_state
FROM flights_stream
WHERE from_state = 'Florida'
EMIT CHANGES;
You can also run aggregations over a stream by using GROUP BY
clauses:
-- What's Florida's favorite destination?
SELECT to_state, count(flight_id)
FROM flights_stream
WHERE from_state = 'Florida'
GROUP BY to_state
EMIT CHANGES;
Was this article helpful?