CodeIgniter Forums
find second highest value from a table - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: find second highest value from a table (/showthread.php?tid=40792)



find second highest value from a table - El Forum - 04-19-2011

[eluser]Bigil Michael[/eluser]
i want to find the second maximum value from a table

can any one help me??
urgent..
thanks in advance


find second highest value from a table - El Forum - 04-19-2011

[eluser]Bigil Michael[/eluser]
query me used
Code:
SELECT * FROM candidate_details
WHERE
candidate_votes IN (SELECT MAX(candidate_votes) FROM candidate_details
WHERE
candidate_votes <> (SELECT MAX(candidate_votes) FROM candidate_details))
this code print correct result.

when i added 2 extra conditions like this
Quote:SELECT * FROM candidate_details
WHERE
candidate_votes IN (SELECT MAX(candidate_votes) FROM candidate_details
WHERE
candidate_votes <> (SELECT MAX(candidate_votes) FROM candidate_details))
AND constituency_id = '2' AND elect_year = '2011'
it prints 0 rows

can anyone help me????
thanks in advance.....


find second highest value from a table - El Forum - 04-19-2011

[eluser]Bigil Michael[/eluser]
can anyone help me??????????