Solved

SQL recordcount

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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:…
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…

734 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