Writing Streaming SQL Queries

Filtering Streams - SQL WHERE

You can perform basic filtering on a stream using the SQL WHERE clause. Given a stream with web login event data, the following query selects only those for which the login was unsuccessful:

SELECT STREAM *
  FROM "WebAppLoginEvents"
 WHERE "loginSuccessful" = FALSE;

Merging Streams - SQL UNION ALL

Streams can be combined using the SQL UNION ALL operator. The resulting output stream simply consists of all rows from both the input streams. For example, the following query produces a stream of orders taken over the phone or via the web:

SELECT STREAM *
  FROM PhoneOrders
UNION ALL
SELECT STREAM *
  FROM WebOrders