problem in finding second maximum value - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: problem in finding second maximum value (/showthread.php?tid=40832) Pages:
1
2
|
problem in finding second maximum value - El Forum - 04-19-2011 [eluser]Bigil Michael[/eluser] can u help me??? iam in a majour problem,no one responding i want to find out the second maximum value Quote:Select candidate_votes,max(candidate_votes) from candidate_details where candidate_votes < (Select max(candidate_votes) from candidate_details) And elect_year = $elect_year And constituency_id = $consti this code is running smoothly as localhost when i upload it to a server it shows error can anyone help me? please.... problem in finding second maximum value - El Forum - 04-19-2011 [eluser]John_Betong_002[/eluser] What is the server error? problem in finding second maximum value - El Forum - 04-19-2011 [eluser]Bigil Michael[/eluser] thanks for your reply this is the code i used Quote:function select_top2($consti,$elect_year) this is the error Quote:A Database Error Occurred problem in finding second maximum value - El Forum - 04-19-2011 [eluser]Bigil Michael[/eluser] can anyone help me?? urgent problem in finding second maximum value - El Forum - 04-20-2011 [eluser]John_Betong_002[/eluser] Look at the error message "there is no GROUP BY clause" I think you should Google for something like PHP MYSQL "GROUP BY" Tutorial and see if you can find where to insert the missing GROUP BY. Best of luck Code: function select_top2($consti,$elect_year) problem in finding second maximum value - El Forum - 04-20-2011 [eluser]Bigil Michael[/eluser] when i execute this query directly on database it shows error like this Quote:#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause i think the problem is here select candidate_votes,max(candidate_votes) problem in finding second maximum value - El Forum - 04-20-2011 [eluser]Bigil Michael[/eluser] now i changed my query to Quote:SELECT max(candidate_votes) as cdv here error removed but some times result is not correct problem in finding second maximum value - El Forum - 04-20-2011 [eluser]John_Betong_002[/eluser] Can you try this: Code: SELECT * If that gives consistent satisfactory results then write some code to select the values from the result. problem in finding second maximum value - El Forum - 04-20-2011 [eluser]Bigil Michael[/eluser] i used this code and it is running smoothly Quote:SELECT * how i select the second maximum value???? problem in finding second maximum value - El Forum - 04-20-2011 [eluser]John_Betong_002[/eluser] Try this: Code: $sql= |