select * from (
select name,row_number() over (partition by id order by id) flag from table
where sid=1
)a where flag <=3