Try this:

select DataAndtime , Value , Tagname from #temp1
where Value in (select MAX(Value) from #temp1 group by Tagname)