By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
| datetime | tenant_id | orders_today |
|---|---|---|
| 2023-06-25 10:00:00 | tenant2 | 2 |
| 2023-06-25 10:00:00 | tenant1 | 1 |
| 2023-06-25 11:00:00 | tenant1 | 5 |
| 2023-06-25 11:00:00 | tenant2 | 2 |
| 2023-06-25 12:00:00 | tenant1 | 5 |
| 2023-06-25 13:00:00 | tenant1 | 6 |
INSERT 0 6
| datetime | sum_orders_today |
|---|---|
| 2023-06-25 10:00:00 | 3 |
| 2023-06-25 11:00:00 | 7 |
| 2023-06-25 12:00:00 | 7 |
SELECT 3