Solved

SQL recordcount

Posted on 2012-04-12
4
418 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
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 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 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