Skip to content

Commit

Permalink
demo polish
Browse files Browse the repository at this point in the history
  • Loading branch information
goodroot committed Oct 8, 2024
1 parent 89ee5ea commit f678650
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
3 changes: 2 additions & 1 deletion reference/function/aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,8 @@ Suppose we want to find all the distinct sky cover types observed in the weather
tablein our public demo:

```questdb-sql title="string_distinct_agg example" demo
SELECT string_distinct_agg(skyCover, ',') AS distinct_sky_covers FROM weather;
SELECT string_distinct_agg(skyCover, ',') AS distinct_sky_covers
FROM weather;
```

This query will return a single string containing all the distinct skyCover
Expand Down
22 changes: 12 additions & 10 deletions reference/function/date-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Return value type is `interval`.

**Examples:**

```questdb-sql title="Construct an interval"
```questdb-sql title="Construct an interval" demo
SELECT interval('2024-10-08T11:09:47.573Z', '2024-10-09T11:09:47.573Z')
```

Expand All @@ -479,7 +479,7 @@ Return value type is `timestamp`.

**Examples:**

```questdb-sql title="Extract an interval lower bound"
```questdb-sql title="Extract an interval lower bound" demo
SELECT
interval_start(
interval('2024-10-08T11:09:47.573Z', '2024-10-09T11:09:47.573Z')
Expand All @@ -504,7 +504,7 @@ Return value type is `timestamp`.

**Examples:**

```questdb-sql title="Extract an interval upper bound"
```questdb-sql title="Extract an interval upper bound" demo
SELECT
interval_end(
interval('2024-10-08T11:09:47.573Z', '2024-10-09T11:09:47.573Z')
Expand All @@ -530,8 +530,10 @@ Return value type is `boolean`

**Examples:**

```questdb-sql
SELECT year(ts), is_leap_year(ts) FROM myTable;
```questdb-sql title="Simple example" demo
SELECT year(timestamp), is_leap_year(timestamp)
FROM trades
limit -1;
```

| year | is_leap_year |
Expand Down Expand Up @@ -649,9 +651,10 @@ Return value type is `int`

**Examples:**

```questdb-sql title="Minute of the hour"
SELECT minute(to_timestamp('2020-03-01:15:43:21', 'yyyy-MM-dd:HH:mm:ss'))
FROM long_sequence(1);
```questdb-sql title="Minute of the hour" demo
SELECT minute(to_timestamp('2022-03-01:15:43:21', 'yyyy-MM-dd:HH:mm:ss'))
FROM trades
LIMIT -1;
```

| minute |
Expand Down Expand Up @@ -854,8 +857,7 @@ Return value is of type `interval`.

**Examples:**

```questdb-sql title="Using today"
```questdb-sql title="Using today" demo
SELECT today() as today, today('CEST') as adjusted;
```

Expand Down
19 changes: 10 additions & 9 deletions reference/operators/date-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ is interchangeable, meaning `BETWEEN X AND Y` is equivalent to
#### Examples

```questdb-sql title="Explicit range"
SELECT * FROM scores
WHERE ts BETWEEN '2018-01-01T00:00:23.000000Z' AND '2018-01-01T00:00:23.500000Z';
SELECT * FROM trades
WHERE timestamp BETWEEN '2022-01-01T00:00:23.000000Z' AND '2023-01-01T00:00:23.500000Z';
```

This query returns all records within the specified timestamp range:
Expand All @@ -43,9 +43,9 @@ This query returns all records within the specified timestamp range:
The `BETWEEN` operator can also accept non-constant bounds. For instance, the
following query returns all records older than one year from the current date:

```questdb-sql title="One year before current date"
SELECT * FROM scores
WHERE ts BETWEEN to_str(now(), 'yyyy-MM-dd')
```questdb-sql title="One year before current date" demo
SELECT * FROM trades
WHERE timestamp BETWEEN to_str(now(), 'yyyy-MM-dd')
AND dateadd('y', -1, to_str(now(), 'yyyy-MM-dd'));
```

Expand All @@ -58,7 +58,7 @@ The result set for this query would be:
| 2018-12-31T23:59:59.999999Z | 115.8 |

```questdb-sql title="Results between two specific timestamps"
SELECT * FROM scores WHERE ts BETWEEN '2018-05-23T12:15:00.000000Z' AND '2018-05-23T12:16:00.000000Z';
SELECT * FROM trades WHERE ts BETWEEN '2022-05-23T12:15:00.000000Z' AND '2023-05-23T12:16:00.000000Z';
```

This query returns all records from the 15th minute of 12 PM on May 23, 2018:
Expand Down Expand Up @@ -206,9 +206,10 @@ LIMIT -1

If we adjust the interval to be not in range, we get no result:

```questdb-sql title="Check if timestamp is in interval failure"
SELECT true as is_in_interval FROM long_sequence(1)
WHERE '2018-05-17T00:00:00Z'::timestamp IN interval('2015', '2016')
```questdb-sql title="Check if timestamp is in interval failure" demo
SELECT true as is_in_interval FROM trades
WHERE '2022-05-17T00:00:00Z'::timestamp IN interval('2022', '2023')
LIMIT -1;
```

| is_in_interval |
Expand Down

0 comments on commit f678650

Please sign in to comment.