| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: view with parameters? How do I convert rows to columns?
Boris,
It is not elegant but it works...
col name form A25
set recsep off
select m1.mlstn_id||chr(10)||m1.name name,
m2.mlstn_id||chr(10)||m2.name name,
m3.mlstn_id||chr(10)||m3.name name
from milestones m1, milestones m2, milestones m3
where m1.proj_proj_id = 101
and m2.mlstn_id(+) > m1.mlstn_id
and m3.mlstn_id(+) > m2.mlstn_id
and not exists ( select null from milestones mc
where mc.proj_proj_id = m1.proj_proj_id
and mc.mlstn_id < m1.mlstn_id
group by mc.proj_proj_id
having mod(count(*),3) <> 0 )
and m2.proj_proj_id(+) = m1.proj_proj_id
and not exists ( select null from milestones mc
where mc.proj_proj_id = m1.proj_proj_id
and mc.mlstn_id < m2.mlstn_id
group by mc.proj_proj_id
having mod(count(*),3) <> 1 )
and not exists ( select NULL from milestones mi
where mi.proj_proj_id = m1.proj_proj_id
and mi.mlstn_id > m1.mlstn_id
and mi.mlstn_id < m2.mlstn_id
and not exists ( select null from milestones mc
where mc.proj_proj_id = m1.proj_proj_id
and mc.mlstn_id < mi.mlstn_id
and mc.mlstn_id < mi.mlstn_id
group by mc.proj_proj_id
having mod(count(*),3) <> 1 ))
and m3.proj_proj_id(+) = m2.proj_proj_id
and not exists ( select null from milestones mc
where mc.proj_proj_id = m1.proj_proj_id
and mc.mlstn_id < m3.mlstn_id
group by mc.proj_proj_id
having mod(count(*),3) <> 2 )
and not exists ( select NULL from milestones mi
where mi.proj_proj_id = m1.proj_proj_id
and mi.mlstn_id > m2.mlstn_id
and mi.mlstn_id < m3.mlstn_id
and not exists ( select null from milestones mc
where mc.proj_proj_id = m1.proj_proj_id
and mc.mlstn_id < mi.mlstn_id
and mc.mlstn_id < mi.mlstn_id
group by mc.proj_proj_id
having mod(count(*),3) <> 2 ));
NAME NAME NAME
------------------------- -------------------------
-------------------------
1 2 3
MS BP MS2 MS3
4 5 6
MS4 MS5 MS6
7 8 9
MS7 MS8 MS9
10 11
MS10 MS11
Regards,
Virag
-- Received on Mon Mar 15 1999 - 08:37:20 CST
![]() |
![]() |