I have a table with a sequence of fields with almost the same name, changing only the final character, and I need to make a query that returns only the columns with some value, I currently do the following:
select pag, descricao,cod_vcto1,cod_vcto2,cod_vcto3,cod_vcto4,cod_vcto5 from tabela_exemplo where pag =2;
pag descricao cod_vcto1 cod_vcto2 cod_vcto3 cod_vcto4 cod_vcto5
2 28 DIAS 28 31 null null null
I would like to return, only 28 DAYS 28/31. But I have 15 columns that start with cod_vcto, which vary from cod_vcto1 to cod_vcto15, is there any way to only select columns that are not null?