?
Solved

SQL recordcount

Posted on 2012-04-12
4
Medium Priority
?
428 Views
Last Modified: 2012-04-12
Im trying to figure out a way to run a query on a table where if a field called [fName] has multiples of the name 'Mike', then 'Bob' and so on.
I want to run a query that pulls these only if there are at least 5 or more of multiples of the [fName] field.
0
Comment
Question by:WebStalkers
[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 13

Expert Comment

by:Ashok
ID: 37839830
Try

select sum(cntFName)
from
(
select count(fName) As cntFName from myTable
group by fName
having count(fName) > 5
);

HTH
Ashok
0
 
LVL 13

Expert Comment

by:Ashok
ID: 37839838
Topic should include SQL Server 2008.
0
 
LVL 5

Accepted Solution

by:
hafeezmca earned 2000 total points
ID: 37839856
Hi,
This query will  list you all the first name whose count is greater than or equal to 5.

SELECT     COUNT(Name) AS Count, FName AS FirstName
FROM         Emp
GROUP BY FName
HAVING      (COUNT(FName) >= 5)

Hope this is what you were looking out for.
0
 
LVL 2

Author Closing Comment

by:WebStalkers
ID: 37839929
Perfect..thanks!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

718 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