Having null count greater than 1

  • Hello,

    I want to display count of records whose null count is greater than 1 group by customer.

    e.g.

    coulumn1 column2

    null 1

    null 1

    123 1

    345 1

    I want to find such records whose null count for coulumn1 is greater than 1 group by column2.

    Please advice on above query.

    Regards

    Shirish phadnis

  • Something like this..

    SELECT Column2, SUM( CASE WHEN Column1 IS NULL THEN 1 ELSE 0 END ) AS NullCount

    FROM TableName

    GROUP BY Column2

    HAVING SUM( CASE WHEN Column1 IS NULL THEN 1 ELSE 0 END ) > 1;


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Thanx Kingston.

    It works

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

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