Solved

count > 1 query

Posted on 2013-11-18
3
189 Views
Last Modified: 2013-11-18
I have the following table design

PlayerID
activitydate

Trying to get a list of playerids that have multiple entries for a specific activitydate

assuming following data

1001  12/01/2012
1002  12/07/2012
1002  07/23/2010
1003  12/01/2012
1001  11//23/2012
1004  03/12/2007
1001  12/01/2012
1002   07/23/2012
1003   12/01/2012

If I am looking for a list of playerid's that occur multiple times for 12/01/2012

I would want the query to return

1001 and 1003

Not sure how to write query
0
Comment
Question by:johnnyg123
[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
3 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39656868
Give this a whirl..
SELECT playerid
FROM yourtable
WHERE the_date = '2012-12-01'
GROUP BY playerid
HAVING COUNT(playerid) > 1
ORDER BY playerid

Open in new window

btw I have an article out there on SQL Server GROUP BY Solutions, and point #3 deals with HAVING.
0
 
LVL 32

Expert Comment

by:awking00
ID: 39656886
select playerid, count(*) from yourtable
where activitydate = '2012-12-01'
group by playerid
having count(*) > 1
order by playerid;
0
 

Author Closing Comment

by:johnnyg123
ID: 39656934
Perfect!   Thanks!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

627 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