diff --git a/processing/sql/temporal-filters.mdx b/processing/sql/temporal-filters.mdx index e79be010..dd487a9b 100644 --- a/processing/sql/temporal-filters.mdx +++ b/processing/sql/temporal-filters.mdx @@ -62,10 +62,10 @@ CREATE SOURCE sales_source(...) with (connector = 'kafka', ...) FORMAT PLAIN ENC CREATE MATERIALIZED VIEW sales AS SELECT * FROM sales_source -WHERE sale_date > NOW() - INTERVAL '1 week'; +WHERE sale_date > NOW() - INTERVAL '7 days'; ``` -The temporal filter in this query is `sale_date > NOW() - INTERVAL '1 week'`. It filters the rows based on the `sale_date` column and checks if it is within one week of the current time or `NOW()`. +The temporal filter in this query is `sale_date > NOW() - INTERVAL '7 days'`. It filters the rows based on the `sale_date` column and checks if it is within one week of the current time or `NOW()`. The following query returns all rows from the `user_sessions` table where the sum of the `last_active` timestamp and double the `session_timeout` duration is greater than the current timestamp, indicating active user sessions. This query could be used to clean up old user sessions from the database by deleting any rows that no longer satisfy the condition.