It is very easy. Here i have a table called Tbl_StuMarks.
id Name Marks
———————-------
1 Pritam 1000
2 Rintu 900
3 Neel 800
4 Nilu 700
5 Rina 600
6 Rama 500
7 Piyali 400
8 Anurag 300
9 Subho 200
10 Raja 100
11 Payel 800
12 Uma 900
13 Sapna 800
14 Shama 400
15 Priya 700
16 Lisa 100
17 Basabi 300
———————-------
1 Pritam 1000
2 Rintu 900
3 Neel 800
4 Nilu 700
5 Rina 600
6 Rama 500
7 Piyali 400
8 Anurag 300
9 Subho 200
10 Raja 100
11 Payel 800
12 Uma 900
13 Sapna 800
14 Shama 400
15 Priya 700
16 Lisa 100
17 Basabi 300
This is the sql query to achive this goal. (In below query please give the value of ‘N’)
SELECT TOP 1 Marks FROM (
SELECT DISTINCT TOP N Marks FROM Tbl_StuMarks
ORDER BY Marks DESC
) AS StuM
ORDER BY Marks
SELECT DISTINCT TOP N Marks FROM Tbl_StuMarks
ORDER BY Marks DESC
) AS StuM
ORDER BY Marks
No comments:
Post a Comment