I would like to see if in my table there exists a column where the entirety of its rows are null.
SELECT * FROM yourTableName
WHERE yourSpecificColumnName IS NULL
-> this will only return the values that are null but i wont know if yourSpecificColumnName is entirely null throughout the table
Using COUNT combined with HAVING
:
COUNT
Returns either the number of non-NULL records for the specified columns , or the total number of records.
SELECT 'Entire_column_is_empty'
FROM yourTable
HAVING COUNT(yourSpecificColumnName) = 0;
or QUALIFY
:
SELECT *
FROM yourTable
QUALIFY COUNT(yourSpecificColumnName) OVER() = 0;
Alternative approach:
SELECT 'Entire_column_is_empty'
FROM yourTable
HAVING MIN(yourSpecificColumnName) = MAX(yourSpecificColumnName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.