MacNuttin
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
5476 51425
NULL 51425
6759 51425
NULL 51425
NULL 51428
NULL 51428
NULL 51429
7793 51429
I need code 51428
What database product and version?
ASKER
T-SQL and it's a temp table of a left join ordered by codes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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.
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.
ASKER
worked like a charm! Thanks for getting me pat the mental block...