我创建了如下表格。我想仅选择NOT NULL列(NO,NAME,SAL_1)。无需选择SAL,SAL_2。如何动态选择非空值列?
注意:最初我不知道列值。
create table sample(no integer,name varchar(20),sal integer,sal_1 integer,sal_2 integer);
insert into sample(name,sal_1) values('aaa',10);
insert into sample(no,name,sal_1) values(20,'',20);
insert into sample(sal_1) values(30);
select * from sample;
数据,如低于
NO NAME SAL SAL_1 SAL_2 20 (null) (null) 20 (null) (null) (null) (null) 30 (null) (null) aaa (null) 10 (null)
预计OP:
NO NAME SAL_1
20 (null) 20
(null) (null) 30
(null) aaa 10
从样品 – mohan111
中选择NO,Name,SAL_1 @Velu:So total no。列表中的列(即5列)将被固定,对吧? –
@KeyurPanchal ..没有列是不固定的。在我的表格中有30列用于示例目的,我只给出了5. – Velu