其中desc1为flag='1' 满足的description列
其中desc2为flag='2' 满足的description列
其中desc3为flag='3' 满足的description列
其中desc2为flag='2' 满足的description列
其中desc3为flag='3' 满足的description列
解决方案 »
- sqlplus连接Oracle时出现的问题
- 求oracle基于web 的管理相关资料
- 问下, odbc oracle ,存储过程怎么执行???调什么函数~~~~~~~~
- 论坛统计发帖数的百分比sql
- oracle数据库net manager 打开为什么每次弹打开网络配置
- 数据库同步老问题没解决,继续问,
- 日期问题,小弟在线等,急~!!
- 关于数据类型DATE的问题
- 64位的2008系统 装32位oracle 配置的报表需要64位
- 安装Grid Infrastructure执行root脚本报错,怎么解决
- 函数变量的赋值的问题(在线急等!)
- char,varchar,varchar2有什么区别?number(n,m)中的n/m各表示什么意思?
(select description desc1 from a where flag='1') a,
(select description desc2 from a where flag='2') b,
(select description desc3 from a where flag='3') c;不知道这是不是LZ想要的
我怎么跑到DB2里来了
我本意是想到ORACLE的
哈哈
本人不懂DB2哈,是把此题当ORACLE来做的
不知道DB2语法什么的有什么不同
LZ 自己修改!
搞笑,哈哈
decode(flag, '1', description, null) as decs1
decode(flag, '2', description, null) as decs2
decode(flag, '3', description, null) as decs3
from
a不知道这是楼主否是想要的结果.
----------
1
2
3Executed in 0.35 secondsSQL> Select decode(col_1,1,col_1) As a,decode(col_1,2,col_1) As b,decode(col_1,3,col_1) As c From test_1; A B C
---------- ---------- ----------
1
2
3Executed in 0.43 secondsSQL> Select a,b,c From (
2 Select col_1 As a From test_1 Where col_1 ='1') x,
3 (Select col_1 As b From test_1 Where col_1='2') y,
4 (Select col_1 As c From Test_1 Where col_1='3') z
5 Where a Is Not Null
6 And b Is Not Null
7 And c Is Not Null
8 / A B C
---------- ---------- ----------
1 2 3Executed in 0.08 seconds
nowait(独行天涯路)
你那种方式,我试了,如果col1=?的时候有满足的多条记录时,就会出现多余的行。
我希望的结果是,结果的行数为各个查询记录的最大行数。
decode(flag, '1', description, null) as decs1
decode(flag, '2', description, null) as decs2
decode(flag, '3', description, null) as decs3
from
a
其中desc2为flag='2' 满足的列
其中desc3为flag='3' 满足的列
记录有多行,怎么来取列description的值?