Solved

Sort by COUNT() - MYSQL

Posted on 2009-07-14
4
436 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

726 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