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 2000 Forums
 SQL Server Development (2000)
 how can I??

Author  Topic 

ram.marella
Starting Member

15 Posts

Posted - 2008-06-06 : 17:54:37
i have the following scenario
TablA

Seg Team
----------------
10 A
10 B
10 C
11 AA
12 Cc
12 Dd

I want to get the output like as follows:
Seg Team
-------------
10 A
10 B
10 C
12 Cc
12 Dd
I want to get the duplicated rows based on the seg column?

Thanks
-----------------
Ram MCP

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-06 : 18:01:37
SELECT Seg, Team
FROM YourTable
GROUP BY Seg, Team
HAVING COUNT(*) > 1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ram.marella
Starting Member

15 Posts

Posted - 2008-06-06 : 19:33:48
Thanks Tara for your reply,
but it is giving disticnt rows based on two columns. But i want to eliminate the unique rows and need to display duplicate rows based on two columns.

Thanks
-----------------
Ram MCP
Go to Top of Page

ram.marella
Starting Member

15 Posts

Posted - 2008-06-06 : 19:43:18
i can put my requirement in simple manner like as follows:
i have to select rows from tableA whihc is having Col1,Col2,Col3 where Col2 value count > 1. i.E in out put rows the Col2 values should be repeated more than once.


Thanks
-----------------
Ram MCP
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-07 : 00:34:38
My query should produce your output. If you have a more complex problem, then please post better data so that we can understand your issue.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-07 : 04:31:34
quote:
Originally posted by ram.marella

i can put my requirement in simple manner like as follows:
i have to select rows from tableA whihc is having Col1,Col2,Col3 where Col2 value count > 1. i.E in out put rows the Col2 values should be repeated more than once.


Thanks
-----------------
Ram MCP



SELECT Seg, Team
FROM YourTable
WHERE Seg IN
(SELECT Seg
FROM YourTable
GROUP BY Seg
HAVING COUNT(*) > 1)


OR

SELECT t.Seg, t.Team
FROM YourTable t
INNER JOIN
(SELECT Seg
FROM YourTable
GROUP BY Seg
HAVING COUNT(*) > 1)tmp
ON tmp.Seg=t.Seg
Go to Top of Page
   

- Advertisement -