Solved

MySQL query question - count(*)

Posted on 2012-03-14
1
391 Views
Last Modified: 2012-03-14
At the moment I'm using this query to count distinct cities with more than 2 businesses.

SELECT DISTINCT bizCity, COUNT(*) as biz_count FROM finance WHERE bizState='$bizState'  GROUP BY bizCity HAVING biz_count > 2

What I would like to do is to select all distinct cities with 100-200 businesses or with 200-300. What is the query in this case?

Thank you
0
Comment
Question by:seopti
1 Comment
 
LVL 40

Accepted Solution

by:
Sharath earned 500 total points
ID: 37722905
DISTINCT is not required as you are already grouping the records.
You can try like this.

SELECT bizCity, COUNT(*) as biz_count FROM finance WHERE bizState='$bizState'  GROUP BY bizCity HAVING COUNT(*) between 100 and 200

SELECT bizCity, COUNT(*) as biz_count FROM finance WHERE bizState='$bizState'  GROUP BY bizCity HAVING COUNT(*) between 200 and 300
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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