Check a script that uses a loop and a series of joins:
create table #Result (ID int, GName nvarchar(100), GDate date, DayDiff int)
insert #Result(ID, GName, GDate, DayDiff)
select t1.ID, t1.GName, t1.GDate, 1
from #MyTable t1
left join #MyTable t2 on t2.ID = t1.ID and t2.GName = t1.GName and t2.GDate < t1.GDate
where t2.ID is null
declare @f int = 1
while @f <> 0
begin
insert #Result(ID, GName, GDate, DayDiff)
select t1.ID, t1.GName, t1.GDate, datediff(day, r1.GDate, t1.GDate)
from #MyTable t1
inner join #Result r1 on r1.ID = t1.ID and r1.GName = t1.GName and datediff(day, r1.GDate, t1.GDate) >= 10
left join #MyTable t2 on t2.ID = t1.ID and t2.GName = t1.GName and datediff(day, r1.GDate, t2.GDate) >= 10 and t2.GDate < t1.GDate
left join #Result r2 on r2.ID = r1.ID and r2.GName = r1.GName and r2.GDate > r1.GDate
where t2.ID is null
and r2.ID is null
set @f = @@ROWCOUNT
end
select *
from #Result
order by ID, GName, GDate