sorry @David i had to move then.mine is almost same. i have assume generate row number per userGUID per eventtypeid date ascending.also each userGUID per event may not have 50 or more rows even in real life.In that case what ?
Declare @API_eventLog table(uid int,EventTypeID int,userGUID uniqueIdentifier,date1 date)
insert into @API_eventLog
values(1, 1, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-17'),
(2, 2, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-17'),
(3, 3, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-18'),
(4, 4, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-18'),
(5, 1, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-19'),
(6, 1, '5B1DCB9D-4EC7-4AAE-BEB1-DC1EA90EA06B', '2013-11-22'),
(7, 1, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-11-06'),
(8, 2, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-11-17'),
(9, 3, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-12-01'),
(10, 2, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-12-07'),
(11, 2, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-12-18'),
(11, 1, '17941D18-CC79-4C29-BBBA-9CBE60993E43', '2013-12-20')
Declare @i int=1
--you can test this other sample data
select * from
(select *,
(select count(*) from @API_eventLog b where b.userGUID=a.userGUID and a.EventTypeID=b.EventTypeID and b.date1<=a.date1) rn
from @API_eventLog a)t4
where rn<=@i
-- you can perform this
delete from t4 from
(select *,
(select count(*) from @API_eventLog b where b.userGUID=a.userGUID and a.EventTypeID=b.EventTypeID and b.date1<=a.date1) rn
from @API_eventLog a)t4
where rn<=@i