Skip to content

Commit

Permalink
Feature / SQL: Reasonably finish page by ...
Browse files Browse the repository at this point in the history
- providing a canonical powerful SQL example
- guiding the reader to the "Advanced Querying" and "All Features" pages
  • Loading branch information
amotl committed Mar 15, 2024
1 parent e89df57 commit 9e16cd8
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions docs/feature/sql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

:::{include} /_include/links.md
:::
:::{include} /_include/styles.html
:::

:::::{grid}
:padding: 0
Expand Down Expand Up @@ -72,10 +74,36 @@ off-the-shelve, 3rd-party, open-source, and proprietary applications.

## Synopsis

:::{todo}
- One or max. two DQL SQL queries using many features, all at once?
- What else?
:::
Use scalar functions, sub-selects, and windowing, specifically illustrating the
DATE_BIN function for resampling time series data using DATE_BIN, also known as
grouping rows into time buckets, aka. time bucketing.

```sql
SELECT
ts_bin,
battery_level,
battery_status,
battery_temperature
FROM (
SELECT
DATE_BIN('5 minutes'::INTERVAL, "time", 0) AS ts_bin,
battery_level,
battery_status,
battery_temperature,
ROW_NUMBER() OVER (PARTITION
BY DATE_BIN('5 minutes'::INTERVAL, "time", 0)
ORDER BY "time" DESC) AS "row_number"
FROM doc.sensor_readings
) x
WHERE "row_number" = 1
ORDER BY 1 ASC
```


## Learn

Please inspect more advanced SQL capabilities on the [](#query) page,
and read about [](#features) in general.



Expand All @@ -87,7 +115,3 @@ off-the-shelve, 3rd-party, open-source, and proprietary applications.
[](#timeseries)
[](#machine-learning)
:::


```{include} /_include/styles.html
```

0 comments on commit 9e16cd8

Please sign in to comment.