I have following table of participants of an apple picking completion. I have a table where all the participants are visible with the number of apples they have picked.
Now i want a table with that shows only the top 3 and the rest will be grouped under 'Others' and the total apples picked should appear against other
I have created the table which will have all the ids and the total apples collected
declare @t table
(
id int,
Apples_picked int
)
insert into @t
select 1,10
union
select 2,12
union
select 3,3
union
select 4,15
union
select 5,23
Required output for the above table
ID Name Apples picked
5 winner 23
4 2nd 15
2 3rd 12
Others 13
I am not sure how to add the everything after 3rd and sum it any guidance is much appreciated