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
 sql syntax

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2011-07-21 : 11:39:21
what is the syntax on finding the same dates in a table? For example seeking the same registration dates, participation dates, exit dates on table called static claimants for an individual(s)?

Roger DeFour

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-21 : 11:52:13
You mean dupliactes?

select *
from tbl
where regdate in (select regdate from tbl group by regdate having count(*) > 1)
order by regdate


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-07-21 : 11:55:28
Please post DDL with specs and not narratives or an invented language. We need keys, DRI actions, and constraints. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. Let us know if you can changed the DDL



--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

Trininole
Yak Posting Veteran

83 Posts

Posted - 2011-07-21 : 12:06:15
what would be the syntax for finding duplicates for all three dates for example the regdate, particpation date and exit date being all the same?

Roger DeFour
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-21 : 12:12:40

select c.*
from claimant c
inner join (select [registration dates], [participation dates], [exit dates] from claimant group by [registration dates], [participation dates], [exit dates] having count(*) > 1) t
on t.[registration dates] = c.[registration dates]
and t.[participation dates]=c.[participation dates]
and t.[exit dates] = c.[exit dates]


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

Go to Top of Page
   

- Advertisement -