Solved

MySQL query question - count(*)

Posted on 2012-03-14
1
407 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
[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
1 Comment
 
LVL 41

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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