I'm looking for a easy function to get the number of datasets (of any table) containing NULL values. It's not important how many columns are involved.
For example:
CREATE TABLE tab1 (
id INTEGER PRIMARY KEY,
dat1 VARCHAR,
dat2 VARCHAR);
INSERT INTO tab1 VALUES
(1, NULL, 'abc'),
(2, 'abc', NULL),
(3, 'abc', 'abc');
SELECT count(*)
FROM tab1
WHERE id IS NULL OR dat1 IS NULL OR dat2 IS NULL;
-- 2
(I know that Primary Keys are not likely to habe NULLs 😉
My current solution uses R to build the query.
Any suggestions?
Best Answer
You will need to use dynamic SQL to acheive this, perhaps like this:
testbed:
function:
query:
result: