17,078
社区成员
发帖
与我相关
我的任务
分享
with table1 as
(
select 'a' col1, 0.1 col2, 'b1' col3, 0.1 col4 from dual union all
select 'a' col1, 0.1 col2, 'b2' col3, 0.2 col4 from dual union all
select 'a' col1, 0.1 col2, 'b3' col3, 0.3 col4 from dual union all
select 'a' col1, 0.1 col2, 'b4' col3, 0.4 col4 from dual union all
select 'a' col1, 0.1 col2, 'b5' col3, 0.5 col4 from dual union all
select 'a' col1, 0.1 col2, 'b6' col3, 0.6 col4 from dual union all
select 'a' col1, 0.1 col2, 'b7' col3, 0.7 col4 from dual union all
select 'a' col1, 0.1 col2, 'b8' col3, 0.8 col4 from dual union all
select 'a' col1, 0.1 col2, 'b9' col3, 0.9 col4 from dual union all
select 'a1' col1, 0.2 col2, 'b13' col3, 0.2 col4 from dual union all
select 'a1' col1, 0.2 col2, 'b14' col3, 0.2 col4 from dual union all
select 'a1' col1, 0.2 col2, 'b15' col3, 0.3 col4 from dual union all
select 'a1' col1, 0.2 col2, 'b16' col3, 0.3 col4 from dual union all
select 'a1' col1, 0.2 col2, 'b17' col3, 0.3 col4 from dual
)
select col1, col2, col3, col4
,(select min(col2)+sum(col4) from table1 b where b.col1=a.col1 and b.col3<=a.col3) col5
,case when (select min(col2)+sum(col4) from table1 b where b.col1=a.col1 and b.col3<=a.col3) < 0.8 then '是' else '否' end col6
from table1 a
order by a.col1, a.col3