How to print duplicate columns values

  • I have a table work which conisist of id column with duplicates values 'John'. one value is with status active and other value with status inactive. How to print duplicates values with status using Tsql.

    Thanks in advance

     

  • I think we may need more information, but here is a start:

    SELECT [id], COUNT( [id]), OtherFields

    FROM MyTable

    GROUP BY [id], OtherFields

    HAVING COUNT( [id]) > 1

     

    I wasn't born stupid - I had to study.

  • -- if you want to see the statuses of the duplicates, do a self join:

    -- pubs db

    -- get titles with multiple authors only

    select distinct

     ta1.title_id,

     ta1.au_id,

     ta2.au_id

    from

     titleauthor ta1

    join

     titleauthor ta2 on ta1.title_id=ta2.title_id and ta1.au_id <> ta2.au_id

  • select empname from employee group by empname HAVING count(empname) > 1

    my mail id : ravi_friends_heart@yahoo.com


    With Regards,

    ANRK

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply