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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select query duplicate rows 4 field combination

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-10-04 : 06:23:19
i want to get records which are appearing more than once with the following 4 field combination from @tempfinal

yearnum, monnum, qtrnum, projid



select yearnum, monnum, qtrnum, progid, projid from @tempfinal


thank you very much for the helpful info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-04 : 06:40:19
[code]select yearnum, monnum, qtrnum, progid, projid
from
(
select count(1) over (partition by yearnum, monnum, qtrnum, progid) as cnt,
yearnum, monnum, qtrnum, progid, projid
from @tempfinal
)t
where cnt>1
[/code]

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

Go to Top of Page
   

- Advertisement -