Study Oracle Document Website

http://www.siue.edu/~dbock/cmis565/

 

 

 

 

 Install oracle on Linux

http://www.dbanotes.net/Oracle/Install-Oracle10g-RHEL3.htm

 

 

 

Offical oracle documentation about dynamic SQL

http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/executeimmediate_statement.htm

 

 

 

select t.station_group,
max(case when rownum =1 then station_id else null end) ||
max(case when rownum =2 then station_id else null end) ||
max(case when rownum =3 then station_id else null end) as station_id
from (select rs.station_group,rs.station_id from routing_station rs
where rownum <=3 order by 1 desc) t group by t.station_group


select t.station_group,
max(case when rownum =1 then station_id else null end) as station_id_1,
max(case when rownum =2 then station_id else null end) as station_id_2,
max(case when rownum =3 then station_id else null end) as station_id_3
from (select rs.station_group,rs.station_id from routing_station rs
where rownum <=3 order by 1 desc) t group by t.station_group

select station_group,substr(sys_connect_by_path(station_id, ','),2) station_id 
from (
select rs.station_id,rs.station_group, count(1) over(partition by rs.station_group) cnt,
row_number() over(partition by rs.station_group order by 1) seq from routing_station rs
)
where seq=cnt start with seq=1
connect by prior seq+1=seq
and prior station_group=station_group

你可能感兴趣的:(oracle,sql,linux,.net)