Ver originalSELECT * FROM(SELECT *,ROW_NUMBER() OVER(Partition BY DAY(fecha),id ORDER BY id) AcumuladoFROM #temp) AS t1