Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Finding records

Author  Topic 

danielc
Starting Member

49 Posts

Posted - 2010-04-12 : 01:39:53
How would I find all records with the same date? The table has 3 columns id, date, and playid. The data is as follows:

ID date playid
1 2004-10-01 45
2 2004-10-05 56
3 2004-10-05 53
4 2006-01-09 13
5 2007-03-04 89

Thank you,

C

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-04-12 : 01:43:52
Whats your expected output?

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-12 : 01:45:36
find record that have more than 1 record with same date ?

select date
from yourtable
group by date
having count(*) > 1



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-12 : 06:08:47
quote:
Originally posted by danielc

How would I find all records with the same date? The table has 3 columns id, date, and playid. The data is as follows:

ID date playid
1 2004-10-01 45
2 2004-10-05 56
3 2004-10-05 53
4 2006-01-09 13
5 2007-03-04 89

Thank you,

C



SELECT t.*
FROM Table t
INNER JOIN (select date
from yourtable
group by date
having count(*) > 1
)t1
ON t1.date = t.date


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

danielc
Starting Member

49 Posts

Posted - 2010-04-12 : 12:25:06
Thank you for the replies. To answer one of the questions, my expected results would be:

ID date playid
2 2004-10-05 56
3 2004-10-05 53


Thank you,

C
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-12 : 13:05:31
quote:
Originally posted by danielc

Thank you for the replies. To answer one of the questions, my expected results would be:

ID date playid
2 2004-10-05 56
3 2004-10-05 53


Thank you,

C


my suggestion would give you this output

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -