locked
Group by RRS feed

  • Question

  • Hi,

    I have table which has two columns, Name and IPAddress as follows

    Name IpAddress
    ABCD 10.2.1.231
    ABCD 10.2.1.231
    ABCD 10.2.1.232
    EFGH 10.2.1.235

    I need to separate IpAddress whose Name is not repeated.

    Thanks in advance.

    Ali

    Wednesday, March 27, 2013 10:37 PM

Answers

  • Your table and sample data make not that much sense. But you may try

    SELECT O.*
    FROM yourTable O
    WHERE O.[Name] IN (
      SELECT I.[Name]
      FROM yourTable I
      WHERE I.IpAddress = O.Address
      GROUP BY I.[Name]
      HAVING Count(I.*) = 1
    );

    • Proposed as answer by Naomi N Thursday, March 28, 2013 3:10 AM
    • Marked as answer by Allen Li - MSFT Thursday, April 4, 2013 2:39 AM
    Wednesday, March 27, 2013 11:24 PM

All replies