Link to home
Start Free TrialLog in
Avatar of MacNuttin
MacNuttinFlag for United States of America

asked on

SQL find the codes that have no value. Multiple codes and null values.

value  code
5476   51425
NULL   51425
6759   51425
NULL  51425
NULL  51428
NULL  51428
NULL  51429
7793   51429

I need code 51428
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

What database product and version?
Avatar of MacNuttin


T-SQL and it's a temp table of a left join ordered by codes
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please explain this logic:
  count(case when value is null then 1 end) =   count(code)
It seams to me if code has any NULL value it will fail so I will try it ...thanks
I group by 'code'.

First half counts the codes that have a null values.
Second half counts the codes overall

When those counts are equal, then that code has ALL null values and it is returned.
worked like a charm! Thanks for getting me pat the mental block...