how to find 2nd largest number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

how to find 2nd largest number

31st Oct 2016, 1:24 PM
Narsa reddy
Narsa reddy - avatar
3 Answers
0
SELECT num FROM table WHERE id= ( SELECT id FROM table WHERE num = num-1 ORDER BY num DESC) Here num is a column where different number value are stored.
5th Nov 2016, 5:24 PM
Solo Player Sabin
Solo Player Sabin - avatar
- 1
You can find the second largest value of column by using the following query: SELECT * FROM TableName a Where 2 = (SELECT count(DISTINCT(b.ColumnName)) FROM TableName b WHERE a.ColumnName <= b.ColumnName);
31st Oct 2016, 1:34 PM
Shovan Lal Saha
Shovan Lal Saha - avatar
- 1
what 2?
31st Oct 2016, 1:38 PM
Narsa reddy
Narsa reddy - avatar