Skip to content
Advertisement

How to detect and remove a column that contains only null values?

In my table table1 there are 6 columns Locations,a,b,c,d,e.

i need the result like

My question is how to detect and delete column that contains all null values using sql query. Is it possible?

If yes then please help and give sample.

Advertisement

Answer

How to detect whether a given column has only the NULL value:

The resultset will either consist of zero rows (column a has a non-NULL value) or one row (column a has only the NULL value). FWIW this code is Standard SQL-92.

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