我要实现一个动态的视图.原表结构是这样的.批号 F1 F2 F3 F4 F5 F6, F1-F6是NUMBER.在实际的业务中,F1-F6不可能同时出现,最多只有其中四种出现.
那现在就要生成一个视图,把其中出现的列出,不出现的字段就不出列出来.
如
批号 F1 F2 F3 F4 F5 F6,
AAAA
BBBB 1
CCCC
DDDD 4
EEEE 4
那么,F1,F2与F4 没有出现,我就要生成如下的视图
批号 F3 as f1 F5 as f2 F6 as f3
再如:
批号 F1 F2 F3 F4 F5 F6,
AAAA 2
BBBB 4 1
CCCC
DDDD 4
EEEE
那么,F4,F6 没有出现,我就要生成如下的视图批号 F1 as f1 F2 as f3 F3 as f3,F5 as f4生成的视图,后面的字段总是f1-f4,不变的.只是内容在变成.
那现在就要生成一个视图,把其中出现的列出,不出现的字段就不出列出来.
如
批号 F1 F2 F3 F4 F5 F6,
AAAA
BBBB 1
CCCC
DDDD 4
EEEE 4
那么,F1,F2与F4 没有出现,我就要生成如下的视图
批号 F3 as f1 F5 as f2 F6 as f3
再如:
批号 F1 F2 F3 F4 F5 F6,
AAAA 2
BBBB 4 1
CCCC
DDDD 4
EEEE
那么,F4,F6 没有出现,我就要生成如下的视图批号 F1 as f1 F2 as f3 F3 as f3,F5 as f4生成的视图,后面的字段总是f1-f4,不变的.只是内容在变成.
解决方案 »
- 其他语言查询问题,求解答
- 一个弱弱的查询问题
- 数据插入oracel出错 请问解决办法
- 如何查询数据表中不满足条件的记录?
- 如何比较一个表中两个查询结果的差积
- 取出oracle数据库中第二条纪录如何取???
- ASP.NET与Oracle连接的奇怪问题!急!
- 高分求sql语句删除一个用户下的所有对象
- 请问用9i的客户端中的EXP 去倒8.0.4.0.0服务器的数据,会不会有问题???请帮忙
- 我用“登录到 Oralce Management server”不能登录到Enterprise Manager Console?
- ORA-01034 ORACLE not available如何解决?
- 如何实现两台电脑中相同数据库的实时同步?(100分)
批号 F1 , F2 ,F3,F5
或
批号 F3 , F5 ,F6也行,我作处理一下,也能用了.谢大哥们帮帮忙呀!比较急.
from
(
select
decode((select count(*) from tab where f1 is not null),0,'',nvl(trim(to_string(f1)),' '))||
f2~f15//按照f1的例子把f2~f15之间的语句补齐了
||decode((select count(*) from tab where f16 is not null),0,'',nvl(trim(to_string(f16)),' ')) f
from tab
);我没测试,看明白思路就知道怎么写了
from
(
select
decode((select count(*) from trsc_bzsjd t where t.fail1 is not null and t.fail1<>0 ),0,'',nvl(trim(to_char(t.fail1,'000000')),''))||
decode((select count(*) from trsc_bzsjd t where t.fail2 is not null and t.fail2<>0 ),0,'',nvl(trim(to_char(t.fail2,'000000')),''))||
decode((select count(*) from trsc_bzsjd t where t.o_s is not null and t.o_s<>0 ),0,'',nvl(trim(to_char(t.o_s,'000000')),''))||
decode((select count(*) from trsc_bzsjd t where t.fail1_eas is not null and t.fail1_eas<>0 ),0,'',nvl(trim(to_char(t.fail1_eas,'000000')),''))||
decode((select count(*) from trsc_bzsjd t where t.fail1_f1 is not null and t.fail1_f1<>0 ),0,'',nvl(trim(to_char(t.fail1_f1,'000000')),''))||
decode((select count(*) from trsc_bzsjd t where t.fail1_f2 is not null and t.fail1_f2<>0 ),0,'',nvl(trim(to_char(t.fail1_f2,'000000')),'')) ffrom trsc_bzsjd t);成功了.谢谢帮忙呀!