;with cteBase as (
Select Name
,datee
,sumval=SUM(val)
,rowNr=ROW_NUMBER() over (Partition By Name Order by sum(Val) Desc)
From @t
GROUP BY rollup(NAME ,datee)
)
Select *
From cteBase
Where RowNr<=4
order by Name, sumval desc