By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| Total | Total_X | Total_Y | Total_Z | DateHour | Cod |
|---|---|---|---|---|---|
| 27 | 1 | 2 | 1 | 2025-06-01 09:00:00.000 | PLRM |
| 22 | 5 | 3 | 0 | 2025-06-01 09:00:00.000 | CTNA |
| 23 | 0 | 1 | 0 | 2025-06-01 21:00:00.000 | PLRM |
| 18 | 3 | 1 | 0 | 2025-06-01 21:00:00.000 | CTNA |
Msg 8120 Level 16 State 1 Line 34
Column 'cte.DateHour' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.