Query

  • Hi all,

    I need some help in writing this query.

    table stucture is :

    col1 col2

    10.69.56.109 A

    10.69.56.109 B

    10.69.56.109 c

    10.69.56.109 D

    10.69.56.109 E

    10.69.56.109 F

    10.69.56.109 G

    If the count of Col1>5 then

    col1 col2

    10.69.56.109 a,b,c,e,f,g

    can anyone help me with this please.

    thx,

    Ravi

  • Hi,

    This is what you are looking for

    declare @Temp table(h varchar(50) ,J varchar(5))

    insert @Temp

    Select '10.69.56.109', 'A'

    UNION ALL Select '10.69.56.109', 'B'

    UNION ALL Select '10.69.56.109', 'C'

    UNION ALL Select '10.69.56.109', 'D'

    UNION ALL Select '10.69.56.109', 'E'

    UNION ALL Select '10.69.56.109', 'F'

    UNION ALL Select '10.69.56.109', 'G'

    -- Select * from @Temp

    SELECT DISTINCT h,SUBSTRING((SELECT ','+j AS [text()] FROM @Temp WHERE h = T.h ORDER BY j FOR XML PATH( '' ) ), 2,200) AS J

    FROM @Temp AS T;

    Thanks
    Parthi

Viewing 2 posts - 1 through 1 (of 1 total)

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