Skip to content

Commit

Permalink
Merge pull request #5377 from BohuTANG/doc-retention
Browse files Browse the repository at this point in the history
chore(doc): better retention example
  • Loading branch information
BohuTANG authored May 14, 2022
2 parents 1d430b0 + 1a56702 commit 45243e9
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,31 @@ The array of 1 or 0.
## Examples

```
CREATE TABLE retention_test(date DATE, uid INT) ENGINE = Memory;
CREATE TABLE retention_test(date DATE, uid INT);
INSERT INTO retention_test SELECT '2018-08-06', number FROM numbers(80);
INSERT INTO retention_test SELECT '2018-08-07', number FROM numbers(50);
INSERT INTO retention_test SELECT '2018-08-07', number FROM numbers(70);
INSERT INTO retention_test SELECT '2018-08-08', number FROM numbers(60);
```

```
SELECT sum(get(r, 0)::TINYINT) as r1, sum(get(r, 1)::TINYINT) as r2 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-07') AS r FROM retention_test WHERE date = '2018-08-06' or date = '2018-08-07' GROUP BY uid);
SELECT sum(r[0]::TINYINT) as r1, sum(r[1]::TINYINT) as r2 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-07') AS r FROM retention_test WHERE date = '2018-08-06' or date = '2018-08-07' GROUP BY uid);
+------+------+
| r1 | r2 |
+------+------+
| 80 | 50 |
| 80 | 70 |
+------+------+
SELECT sum(get(r, 0)::TINYINT) as r1, sum(get(r, 1)::TINYINT) as r2 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-08') AS r FROM retention_test WHERE date = '2018-08-06' or date = '2018-08-08' GROUP BY uid);
SELECT sum(r[0]::TINYINT) as r1, sum(r[1]::TINYINT) as r2 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-08') AS r FROM retention_test WHERE date = '2018-08-06' or date = '2018-08-08' GROUP BY uid);
+------+------+
| r1 | r2 |
+------+------+
| 80 | 60 |
+------+------+
SELECT sum(get(r, 0)::TINYINT) as r1, sum(get(r, 1)::TINYINT) as r2, sum(get(r, 2)::TINYINT) as r3 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-07', date = '2018-08-08') AS r FROM retention_test GROUP BY uid);
SELECT sum(r[0]::TINYINT) as r1, sum(r[1]::TINYINT) as r2, sum(get(r, 2)::TINYINT) as r3 FROM (SELECT uid, retention(date = '2018-08-06', date = '2018-08-07', date = '2018-08-08') AS r FROM retention_test GROUP BY uid);
+------+------+------+
| r1 | r2 | r3 |
+------+------+------+
| 80 | 50 | 60 |
| 80 | 70 | 60 |
+------+------+------+
```

1 comment on commit 45243e9

@vercel
Copy link

@vercel vercel bot commented on 45243e9 May 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend.vercel.app
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs

Please sign in to comment.