Solved

SQL recordcount

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

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

I was asked if I could set up a fax machine so that incoming faxes were delivered to people's Exchange inboxes and so that they could send faxes from their desktops without needing to print the document first.  I knew it was possible but I had no id…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now