Skip to content
Advertisement

How to select columns from a table which have non null values?

I have a table containing hundreds of columns many of which are null, and I would like have my select statement so that only those columns containing a value are returned. It would help me analyze data better. Something like:

Select (non null columns) from tablename;

I want to select all columns which have at least one non-null value.

Can this be done?

Advertisement

Answer

Have a look as statistics information, it may be useful for you:

For example you can check if NUM_NULLS = NUM_ROWS to identify “empty” columns.
Reference: ALL_TAB_COLUMNS, ALL_TABLES.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement