I have a table with 70 plus columns. I often search the table for a single row.
Ex:
select * from customer where customer_id='xyz';
The customer_id is unique.
In the result, there will most probably be 30 to 40 columns with null value.
I am always interested only in the non-null fields.
Is there a way in SQL to list out only those columns that are non-null?
PS: Unfortunately, the non-null fields will not be the same fields for all customers. Say, If 'Customer A' has null in 'Column R', 'Customer B' might have a valid value in that column. And lastly, my query will always be focused on only 1 customer at any given time.
Brief example:
query:
select * from customer where cust_id='826122';
actual result:
cust_id - 826122
cust_fname - martha
cust_lname - kane
cust_alt_add - null
cust_cell_acode - 210
cust_home_phone - null
expected result: (I don't want the columns with null values to appear in my result)
cust_id - 826122
cust_fname - martha
cust_lname - kane
cust_cell_acode - 210