select * from tb_Price a where UpdateTime= (select max(UpdateTime) from tb_Price where Type=a.Type) order by a.Type
select * from tb_Price a where not exists(select 1 from tb_Price where Type=a.Type and UpdateTime>a.UpdateTime)
select type, max(UpdateTime) as UpdateTime, cast(substring(max(convert(varchar(19), updatetime, 20) + convert(varchar(18), price)), 20, 18) as decimal(18,2)) as price from tb_price group by type
SELECT Type, Price, UpdateTime FROM ( SELECT Type, Price, UpdateTime ,ROW_NUMBER() OVER (PARTITION BY Type ORDER BY UpdateTime DESC) AS Num FROM TB) AS Temp WHERE Num = 1
select * from tb tb1 where not exits (select 1 from tb where tb1.type=type and tb1.UpdateTime < UpdateTime )
select * from tb_Price a where not exists(select 1 from tb_Price where Type=a.Type and UpdateTime>a.UpdateTime)
select * from tb t where UpdateTime=(select max(UpdateTime) from tb where type=t.type )
(select max(UpdateTime) from tb_Price where Type=a.Type)
order by a.Type
where not exists(select 1 from tb_Price where Type=a.Type
and UpdateTime>a.UpdateTime)
max(UpdateTime) as UpdateTime,
cast(substring(max(convert(varchar(19), updatetime, 20) + convert(varchar(18), price)), 20, 18) as decimal(18,2)) as price
from tb_price group by type
SELECT Type, Price, UpdateTime
FROM (
SELECT Type, Price, UpdateTime
,ROW_NUMBER() OVER (PARTITION BY Type ORDER BY UpdateTime DESC) AS Num
FROM TB) AS Temp
WHERE Num = 1
from tb tb1
where not exits (select 1 from tb where tb1.type=type and tb1.UpdateTime < UpdateTime )
where not exists(select 1 from tb_Price where Type=a.Type
and UpdateTime>a.UpdateTime)
*
from
tb t
where
UpdateTime=(select max(UpdateTime) from tb where type=t.type )