在oracle 中有张表mytest,记录是这样的:(第一列是列名)
owner 产品线 产品族 产品
test16 29-7 29-8
test15 29-7
test16 29-7 29-8 29-9查询出:
如果产品不为空获取产品不为空对应的那条记录的 owner,产品线,产品族,产品
如果产品为空,则获取产品族的
如果产品为空且产品族也为空,则获取产品线的
(相当是一个树关系 产品线 下挂 产品族 产品族 下挂 产品 )请大家帮忙看下能否写出这样的sql, 多谢!
owner 产品线 产品族 产品
test16 29-7 29-8
test15 29-7
test16 29-7 29-8 29-9查询出:
如果产品不为空获取产品不为空对应的那条记录的 owner,产品线,产品族,产品
如果产品为空,则获取产品族的
如果产品为空且产品族也为空,则获取产品线的
(相当是一个树关系 产品线 下挂 产品族 产品族 下挂 产品 )请大家帮忙看下能否写出这样的sql, 多谢!
解决方案 »
- 关于子查询的。。。
- 【求高手扫盲】oracle中的role和system privilege
- Oracle WebLogic Server 10g R3
- 求助 基于oracle的论文
- 同一个问题 再发。麻烦高手看看
- 关于数据库设计的问题(觅高手!)
- 把数据表中clob类型字段中的回车替换成"<br>"
- sqlserver 中的SET LOCK_TIMEOUT ,在oracle中还有类似的意义么
- 各位高手来看看小弟IMP的时候,为什么出错!!
- 求救!怎样才能把oracle 8.17中的数据库导到oracle8.16上!
- 单表查询 有两个字段相同,一个字段不同,合并不同字段,删除一个
- 怎么删除物化视图日志
with t as(
select 'test16' owner,'29-7' a,'29-8' b,'' c from dual
union all
select 'test15' owner,'29-7' a,'' b,'' c from dual
union all
select 'test16' owner,'29-7' a,'29-8' b,'29-9' c from dual
)select t_out.owner,t_out.a,t_out.b,t_out.c
from (
select t.owner,t.a,t.b,t.c,row_number() over(partition by t.owner order by t.c,t.b,t.a) cn
from t ) t_out
where t_out.cn = 1
select * from
(
select owner,productline,productfamily,product,id,row_number() over(partition by owner order by product) cn
from mytest ) t_out
where t_out.cn = 1