--■■■model句を使う方法(10g以降)■■■
select ID,Order_D,Process_D,Verified,shipped
from NRowsTable
model
partition by(ID)
dimension by(1 as soeji)
measures(Order_D,Process_D,to_date(null) as Verified,to_date(null) as shipped)
rules(
Order_D [for soeji in(2,3)] = Order_D[1],
Process_D[for soeji in(2,3)] = Process_D[1],
Verified [for soeji in(2,3)] = Order_D[1]+2,
shipped[3] = Order_D[1]+3)
order by ID,soeji;
--■■■grouping setsを使う方法■■■
select ID,Order_D,Process_D,
case when group_ID() in(1,2) then Order_D+2 end as Verified,
decode(group_ID(),2,Order_D+3) as shipped
from NRowsTable
group by grouping sets((ID,Order_D,Process_D),
(ID,Order_D,Process_D),
(ID,Order_D,Process_D))
order by ID,Verified desc,shipped desc;
--■■■union allを使う方法■■■
select ID,Order_D,Process_D,to_date(null) as Verified,to_date(null) as shipped from NRowsTable
union all
select ID,Order_D,Process_D,Order_D+2,to_date(null) from NRowsTable
union all
select ID,Order_D,Process_D,Order_D+2,Order_D+3 from NRowsTable
order by ID,4 desc,5 desc;
--■■■クロスジョインを使う方法■■■
select a.ID,a.Order_D,a.Process_D,
case when b.Column_Value in(2,3)
then a.Order_D +2 end as Verified,
decode(b.Column_Value,3,a.Order_D+3) as shipped
from NRowsTable a,table(sys.odciNumberList(1,2,3)) b
order by a.ID,Verified desc,shipped desc;