Solved

SQL recordcount

Posted on 2012-04-12
4
414 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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Ashok
Comment Utility
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
Comment Utility
Topic should include SQL Server 2008.
0
 
LVL 5

Accepted Solution

by:
hafeezmca earned 500 total points
Comment Utility
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
Comment Utility
Perfect..thanks!
0

Featured Post

Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

Join & Write a Comment

We recently had an issue where out of nowhere, end users started indicating that their logins to our terminal server were just showing a "blank screen." After checking the usual suspects -- profiles, shell=explorer.exe in the registry, userinit.exe,…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now