I am not from a DBMS background and I couldn't find much help from reading some resources once.
I have a requirement like: There are 5 interfaces with some execution time. My goal is to find the top 2 interfaces which took the most time.
RowNum Interface TIME
1 Intf1 0
2 Intf2 3
3 intf5 1
4 Intf2 4
5 intf3 3
6 Intf2 2
7 intf3 5
8 intf3 2
9 inft4 2
10 Intf2 0
11 intf5 1
The max time taken is 5 which corresponds to Intf3 (so print all intf3 with their times) and the second max time taken is 4 corresponding to Intf2(so print all intf2 with their times). So my expected output is:
RowNum Interface TIME
7 intf3 5
5 intf3 3
8 intf3 2
4 Intf2 4
2 Intf2 3
6 Intf2 2
10 Intf2 0
I tried something like
select Row,Interface,Time
from (select Row,Interface,Time from NAMES order by Time desc)
but it didn't seem to work as I was expecting.