By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 13
| user_id | user_position | position_start | position_end |
|---|---|---|---|
| 1 | 1 | 2019-01-01 | 2019-01-02 |
| 1 | 2 | 2019-01-03 | 2019-01-04 |
| 1 | 1 | 2019-01-05 | 2019-01-06 |
| 2 | 1 | 2019-01-01 | 2019-01-03 |
| 2 | 2 | 2019-01-04 | 2019-01-05 |
| 2 | 2 | 2019-01-08 | 2019-01-08 |
| 2 | 2 | 2019-01-10 | 2019-01-10 |
SELECT 7