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)
 want to get matched recods(if name in both locati

Author  Topic 

purushotham216
Starting Member

14 Posts

Posted - 2010-09-18 : 03:03:48
hi to all .thanks in advance

I want to get matched recods(if name in both locations ) from table

Table is like this

Name Location

a loc1

b loc1

a loc2


o/p (name a in both locations loc1 and loc2)

a loc1
a loc2

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-18 : 09:09:29
[code]
SELECT Name, Location
FROM
(SELECT COUNT(1) OVER (PARTITION BY Name) AS Cnt,Name, Location
FROM Table)t
WHERE Cnt >1
[/code]

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

Go to Top of Page
   

- Advertisement -