Solved

MySQL query pull data greater than 20

Posted on 2011-03-09
4
242 Views
Last Modified: 2012-05-11
i have a table called agent.  this table has a field called officeName.  

How do I select all distinct officeName where there are more than 20 instances of agents for that office?
0
Comment
Question by:pda4me
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 500 total points
ID: 35083334
select officename from agent group by officename having count(*) > 20
0
 
LVL 2

Expert Comment

by:alagurjan
ID: 35083701
i think in the above query good to add this small change :)

select distinct(officename) from agent group by officename having count(*) > 20
0
 
LVL 15

Expert Comment

by:derekkromm
ID: 35083709
shouldn't need the distinct with the group by
0
 

Author Closing Comment

by:pda4me
ID: 35083739
Worked AWESOME!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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