SELECT column for a row only if its value is not empty

sqlite

I want to display a certain column only if its value is not empty.

Pseudo code:

SELECT column1, IF_NOT_EMPTY(column2), ... FROM table;

Will display all columns except column2 if column2 is empty.

Best Answer

Not sure there is a way to do that with standard sql you could use case to change that blank to a value https://www.geeksforgeeks.org/sql-case-statement/

The consensus here was that this shouldn't be done on the DB side rather, in whatever mechanism is presenting the data: Hide column if any value is null or zero via proc sql or view