From 77aed8468ffee13ec7f58ca1303a5a0eb8782a31 Mon Sep 17 00:00:00 2001 From: meelahme Date: Thu, 31 Jul 2025 22:26:53 -0700 Subject: [PATCH] docs: tested and updated examples --- content/shared/sql-reference/where.md | 28 +++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/content/shared/sql-reference/where.md b/content/shared/sql-reference/where.md index bebdd7efc..40bbfb81e 100644 --- a/content/shared/sql-reference/where.md +++ b/content/shared/sql-reference/where.md @@ -111,7 +111,7 @@ WHERE "location" = 'santa_monica' ``` {{< expand-wrapper >}} -{{% expand "View query explanation" %}} +{{% expand "View example results" %}} This query filters data to include only records from the previous calendar day: @@ -119,10 +119,19 @@ This query filters data to include only records from the previous calendar day: - `DATE_TRUNC('day', ...)` truncates to the start of that day (00:00:00) - The range spans from yesterday at 00:00:00 to today at 00:00:00 +| level description | location | time | water_level | +| :---------------- | :----------- | :----------------------- | :---------- | +| below 3 feet | santa_monica | 2019-08-18T12:00:00.000Z | 2.533 | +| below 3 feet | santa_monica | 2019-08-18T12:06:00.000Z | 2.543 | +| below 3 feet | santa_monica | 2019-08-18T12:12:00.000Z | 2.385 | +| below 3 feet | santa_monica | 2019-08-18T12:18:00.000Z | 2.362 | +| below 3 feet | santa_monica | 2019-08-18T12:24:00.000Z | 2.405 | +| below 3 feet | santa_monica | 2019-08-18T12:30:00.000Z | 2.398 | + {{% /expand %}} {{< /expand-wrapper >}} -#### Get data from the last 24 hour +#### Get data from the last 24 hours ```sql SELECT * @@ -131,10 +140,19 @@ WHERE time >= NOW() - INTERVAL '1 day' ``` {{< expand-wrapper >}} -{{% expand "View query explanation" %}} +{{% expand "View example results" %}} This query returns data from exactly 24 hours before the current time. Unlike the "yesterday" example, this creates a rolling 24-hour window that moves with the current time. +| level description | location | time | water_level | +| :---------------- | :----------- | :----------------------- | :---------- | +| below 3 feet | santa_monica | 2019-08-18T18:00:00.000Z | 2.120 | +| below 3 feet | santa_monica | 2019-08-18T18:06:00.000Z | 2.028 | +| below 3 feet | santa_monica | 2019-08-18T18:12:00.000Z | 1.982 | +| below 3 feet | santa_monica | 2019-08-19T06:00:00.000Z | 1.825 | +| below 3 feet | santa_monica | 2019-08-19T06:06:00.000Z | 1.753 | +| below 3 feet | santa_monica | 2019-08-19T06:12:00.000Z | 1.691 | + {{% /expand %}} {{< /expand-wrapper >}} @@ -147,10 +165,12 @@ WHERE time >= DATE_TRUNC('week', NOW()) ``` {{< expand-wrapper >}} -{{% expand "View query explanation" %}} +{{% expand "View example results" %}} This query returns all data from the start of the current week (Monday at 00:00:00) to the current time. The DATE_TRUNC('week', NOW()) function truncates the current timestamp to the beginning of the week. +level description location timew ater_levelbelow 3 feetsanta_monica2019-08-12T00:00:00.000Z2.064below 3 feetsanta_monica2019-08-14T09:30:00.000Z2.116below 3 feetsanta_monica2019-08-16T15:45:00.000Z1.952below 3 feetsanta_monica2019-08-18T12:00:00.000Z2.533below 3 feetsanta_monica2019-08-18T18:00:00.000Z2.385below 3 feetsanta_monica2019-08-19T10:30:00.000Z1.691 + {{% /expand %}} {{< /expand-wrapper >}}