create table T (dt datetime, t float, h time)
select FORMAT(dt, 'yyyy-dd') as dt, max(t) as t, FORMAT(dt,'hh:mm') as h
from T
group by dt
go
select FORMAT(dt, 'yyyy-MM-dd') as d, max(t) as t
from T
group by FORMAT(dt, 'yyyy-MM-dd');
select max_t.*, FORMAT(T.dt, 'HH:mm') hour
from (
select FORMAT(dt, 'yyyy-MM-dd') as date, max(t) as max_t
from T
group by FORMAT(dt, 'yyyy-MM-dd')
) max_t
join T on FORMAT(T.dt, 'yyyy-MM-dd') = max_t.date and T.t = max_t.max_t;
CREATE TABLE T (dt DATETIME, t FLOAT)
INSERT T VALUES ( '20060706 00:10', 24.0),
( '20060706 10:00', 25.0),
( '20060706 07:00', 21.0),
( '20060707 01:10', 7.0)
SELECT CONVERT(VARCHAR, dt, 104) AS [Дата],
T.t AS [Температура],
LEFT(CONVERT(VARCHAR, dt, 108),7) AS [Время]
FROM T
INNER JOIN ( SELECT CONVERT(VARCHAR, dt, 112) AS D, MAX(t) AS T
FROM T
GROUP BY CONVERT(VARCHAR, dt, 112)) AS MT
ON MT.D = CONVERT(VARCHAR, T.dt, 112) AND MT.T = T.t
ORDER BY dt