Solved

Sort by COUNT() - MYSQL

Posted on 2009-07-14
4
443 Views
Last Modified: 2012-05-07
Hi, I have the following mysql query;

SELECT idea_id, COUNT(vote_id) FROM int_votes GROUP BY idea_id ORDER BY COUNT(vote_id) DESC

I want to sort the results by the COUNT, but when I try the above it says 'invalid use of group'.

Can anyone tell me where I'm going wrong?
0
Comment
Question by:SheppardDigital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
Mushq earned 500 total points
ID: 24847762
0
 
LVL 14

Expert Comment

by:flob9
ID: 24847775
Your query seems fine to me
0
 

Author Closing Comment

by:SheppardDigital
ID: 31603185
I changed my query to
SELECT idea_id, COUNT(vote_id) as count FROM int_votes GROUP BY idea_id ORDER BY count DESC
0
 
LVL 14

Expert Comment

by:flob9
ID: 24847807
The first version was working on mysql 5 ... good point mushq :)
0

Featured Post

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question