How to get information how many rows in a table have particular number of nulls in it?
I want to get something like this:
Number of nulls | Number of rows
0 | 10
1 | 4
2 | 11
Motivation:
I need this for data mining purposes. If for example I have an observation that has in almost all columns null value then I need to get rid of this observation, but there can be also a situation where many observations have small value of nulls which is acceptable.
With just SQL, you’ll have to resort to unpleasant code, something like:
Also note that not all SQL dialects support referencing a calculated column by alas in the
GROUP BYclause, so you might end up with a much uglier query. Needless to say, you’ll also have to make a different query for each table. You could of course generate the query using someINFORMATION_SCHEMAvoodoo…