Hi All,

In my table (dbo.partha) i have three fields. the first one is id, 2nd one is CM_Name and the last one is empid
the table looks like

id name empid
1 Das 5
2 Ram 9
3 Abi 5
1 Wed 5
4 Sat 4
5 Sun 3
2 Wed 9
7 Fri 2
2 Thu 9
3 Mon 8

Now i want to see only those records where I have same id and empid

I tired a one and got the blow result

select distinct id, empid from dbo.partha where id in (
select id from dbo.partha group by id having COUNT(id) > 1)

id empid
1 5
2 9
3 5
3 8

But i dont that one. I want only those where the same id and empid will come

the result will look like

id empid
1 5
2 9

Please help!

Here you go...

select id, empid from dbo.partha
group by id, empid
having COUNT(id) > 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.