I have the same problem as mentioned in In SQL, how to select the top 2 rows for each group. The answer is working fine. But it takes too much time. How to optimize this query?
Example: sample_table
act_id: act_cnt: 1 1 2 1 3 1 4 1 5 1 6 3 7 3 8 3 9 4 a 4 b 4 c 4 d 4 e 4
Now i want to group it (or using some other ways). And i want to select 2 rows from each group. Sample Output:
act_id: act_cnt: 1 1 2 1 6 3 7 3 9 4 a 4
I am new to SQL. How to do it?