Hi @Maggie
You only need one analytical ranking function. You can try this query.
;with CTE as(
select A,B,C,row_number()over(partition by A,B order by C) as num from table)
select * from CTE where num < 3;
If you still have problems, you can provide your source data and the results you expect to output.
Best regards,
Percy Tang
If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.