CodeIgniter Forums
select 2nd maximum problem - 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: select 2nd maximum problem (/showthread.php?tid=40796)



select 2nd maximum problem - El Forum - 04-19-2011

[eluser]Bigil Michael[/eluser]
Quote:function select_top2($consti,$elect_year)
{
$result_category = $this->db->query("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");
return $result_category->row();
}

I have used this query to find the second maximum value

it works smoothly as localhost

when i upload it to the server
it shows an error
like this

Quote:A Database Error Occurred

Error Number: 1140

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

Select candidate_votes,max(candidate_votes) from candidate_details where candidate_votes < (Select max(candidate_votes) from candidate_details) And elect_year = 2005 And constituency_id = 2

i dont know what is the problem
can anyone help me????
urgent
thanks in advance...