一、oracle橫列轉(zhuǎn)換
- ----行列互換
- select t.* from temp_sc t;
- select sc.stdname, a.grade 語(yǔ)文, b.grade 數(shù)學(xué), c.grade 物理, d.grade 化學(xué)
- from (select distinct stdname from temp_sc) sc,
- (select stdname, grade from temp_sc where stdsubject = '語(yǔ)文') a,
- (select stdname, grade from temp_sc where stdsubject = '數(shù)學(xué)') b,
- (select stdname, grade from temp_sc where stdsubject = '物理') c,
- (select stdname, grade from temp_sc where stdsubject = '化學(xué)') d
- where sc.stdname = a.stdname
- and sc.stdname = b.stdname
- and sc.stdname = c.stdname
- and sc.stdname = d.stdname;
----行列互換select t.* from temp_sc t;select sc.stdname, a.grade 語(yǔ)文, b.grade 數(shù)學(xué), c.grade 物理, d.grade 化學(xué) from (select distinct stdname from temp_sc) sc, (select stdname, grade from temp_sc where stdsubject = '語(yǔ)文') a, (select stdname, grade from temp_sc where stdsubject = '數(shù)學(xué)') b, (select stdname, grade from temp_sc where stdsubject = '物理') c, (select stdname, grade from temp_sc where stdsubject = '化學(xué)') d where sc.stdname = a.stdname and sc.stdname = b.stdname and sc.stdname = c.stdname and sc.stdname = d.stdname;
二、樹(shù)
- --從哪條開(kāi)始 start with
- --連表?xiàng)l件 connect by
- --往上還是往下 prior
- --從哪條開(kāi)始 start with
- --連表?xiàng)l件 connect by
- --往上還是往下 prior
- select *
- from tbl_tree
- start with uuid = 1
- connect by prior uuid = puuid
- order by puuid
--從哪條開(kāi)始 start with--連表?xiàng)l件 connect by--往上還是往下 prior--從哪條開(kāi)始 start with--連表?xiàng)l件 connect by--往上還是往下 priorselect *from tbl_treestart with uuid = 1connect by prior uuid = puuidorder by puuid
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。