What's wrong with this bit of code? $results = mysql_query("SELECT email, SUM(confirm) AS total FROM survey WHERE prize = 'bf3' GROUP BY ip ORDER BY total DESC"); I'm trying to rank people for a prize where the prize is "bf3" and sum the "confirm" column (where the actual sum comes from). Can't figure out what's wrong.
is it giving some error? or query is working fine but not giving desired output? it would be great if you can share sample data and table structure.
What error are you getting? I notice that you're selecting email but grouping by ip. This is not OK in standard SQL - you can only select columns that you are grouping by or aggregates (such as count(*)). We need to know what the error is.
It didn't throw any errors for some reason. I then changed the prize to 'game' instead of 'bf3' and it worked, literally, nothing else changed except the prize. I've run into this before with more common words though, not this, for example: "order."