Reputation: 39
I have a table called 'reviews' that I want to start the data cleaning process, so I want to find out if there are any records that have any NULL columns (there are 6 columns in the table).
So, instead of using the code below:
SELECT *
FROM reviews
WHERE listing_id IS NULL
OR id IS NULL
OR date IS NULL
OR reviewer_id IS NULL
OR reviewer_name IS NULL
OR comments IS NULL
'''
I would like to simplify the code, using something like this:
SELECT *
FROM reviews
WHERE ANY( ARRAY [listing_id, id, date, reviewer_id, reviewer_name, comments]) IS NULL
But It doesn't work.
Upvotes: 0
Views: 34
Reputation:
you can use num_nulls()
where num_nulls(listing_id, id, date, reviewer_id, reviewer_name, comments) > 0
Upvotes: 4