By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| version |
|---|
| PostgreSQL 13.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10), 64-bit |
8 rows affected
| stock_id | open | date_value |
|---|---|---|
| 1 | 10 | 2020-12-01 09:31:00 |
| 1 | 12 | 2020-12-01 09:46:00 |
| 1 | 14 | 2020-12-02 09:31:00 |
| 1 | 20 | 2020-12-02 09:46:00 |
| 2 | 14 | 2020-12-01 09:31:00 |
| 2 | 16 | 2020-12-01 09:46:00 |
| 2 | 2 | 2020-12-02 09:31:00 |
| 2 | 16 | 2020-12-02 09:46:00 |
| average_difference | stock_id |
|---|---|
| 4 | 1 |
| 8 | 2 |