【发布时间】:2017-07-04 11:01:06
【问题描述】:
我创建了一个如下所示的表格。我只想动态选择 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)
预期操作:
NO NAME SAL_1
20 (null) 20
(null) (null) 30
(null) aaa 10
【问题讨论】:
-
从样本中选择 NO ,Name,SAL_1
-
@Velu:总之没有。表格中的列数(即 5 列)将被固定,对吗?
-
@KeyurPanchal ..没有列是不固定的。在我的表中有 30 列用于示例目的,我只给出了 5 列。