
从上面那张表拉链到下面表。怎么得到。用传统关系型oracle sql实现
写好了吗?代码如下,如果有用,望采纳,谢谢!
with temp as (select acct_no,current_bal,txn_dt,row_number() over(partition by acct_no order by txn_dt) as rn from t03_acctno_bal)
select t1.acct_no as acctno,t1.txn_dt as start_dt,nvl(t2.txn_dt,'3000-12-31') as end_dt,t1.current_bal from temp t1 left join temp t2 on t1.acct_no = t2.acct_no and t1.rn+1=t2.rn