Skip to content

Commit 9e16cd8

Browse files
committed
Feature / SQL: Reasonably finish page by ...
- providing a canonical powerful SQL example - guiding the reader to the "Advanced Querying" and "All Features" pages
1 parent e89df57 commit 9e16cd8

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

docs/feature/sql/index.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
:::{include} /_include/links.md
66
:::
7+
:::{include} /_include/styles.html
8+
:::
79

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

7375
## Synopsis
7476

75-
:::{todo}
76-
- One or max. two DQL SQL queries using many features, all at once?
77-
- What else?
78-
:::
77+
Use scalar functions, sub-selects, and windowing, specifically illustrating the
78+
DATE_BIN function for resampling time series data using DATE_BIN, also known as
79+
grouping rows into time buckets, aka. time bucketing.
80+
81+
```sql
82+
SELECT
83+
ts_bin,
84+
battery_level,
85+
battery_status,
86+
battery_temperature
87+
FROM (
88+
SELECT
89+
DATE_BIN('5 minutes'::INTERVAL, "time", 0) AS ts_bin,
90+
battery_level,
91+
battery_status,
92+
battery_temperature,
93+
ROW_NUMBER() OVER (PARTITION
94+
BY DATE_BIN('5 minutes'::INTERVAL, "time", 0)
95+
ORDER BY "time" DESC) AS "row_number"
96+
FROM doc.sensor_readings
97+
) x
98+
WHERE "row_number" = 1
99+
ORDER BY 1 ASC
100+
```
101+
102+
103+
## Learn
104+
105+
Please inspect more advanced SQL capabilities on the [](#query) page,
106+
and read about [](#features) in general.
79107

80108

81109

@@ -87,7 +115,3 @@ off-the-shelve, 3rd-party, open-source, and proprietary applications.
87115
[](#timeseries)
88116
[](#machine-learning)
89117
:::
90-
91-
92-
```{include} /_include/styles.html
93-
```

0 commit comments

Comments
 (0)