Click to copy

• 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;
Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like