Hi,
I'm working on a poll script and I'm having difficulty getting the syntax right on this query. What I want to do is determine which poll_item was voted for the most.
I start out with:
Code:
SELECT i.item_name, count(v.vote_value)
FROM poll_items i LEFT JOIN poll_votes v
USING (item_id, poll_id)
WHERE i.poll_id=2
GROUP BY i.item_name
ORDER BY i.item_id;
This gives me a 2 column table with all the items for a particular poll and their scores. I want to select the row from this table that contains the max score. I keep getting 'Invalid use of group function' when I try to return a row. I am successful returning the max(count(v.vote_value)) without its associated item_name, but that's not useful .
thanx
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --