By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 11
| agent_id | start_dt | end_dt |
|---|---|---|
| 666 | 2024-01-26 01:00:00 | 2024-01-26 02:00:00 |
| 666 | 2024-01-26 03:00:00 | null |
| 3148 | 2024-01-25 12:30:02 | 2024-01-25 22:23:57 |
| 3148 | 2024-01-25 22:24:57 | null |
SELECT 4
CREATE FUNCTION
| agent_id | start_dt | end_dt |
|---|---|---|
| 666 | 2024-01-26 01:00:00 | 2024-01-26 02:00:00 |
| 666 | 2024-01-26 03:00:00 | null |
| 3148 | 2024-01-25 12:30:02 | 2024-01-25 22:23:57 |
| 3148 | 2024-01-25 22:24:57 | null |
SELECT 4