Home > database >  PL/SQL implementation procession conversion
PL/SQL implementation procession conversion

Time:10-26

I have a question

is how to realize the column turned

Use the pivot a

tried several times didn't success
don't know why

Don't baidu to



Normal text: kalimantan island belongs to the tropical rain forest, most of the island is navigable rivers, an important lifeline for trade and business activity, often is the only lifeline, northern island is narrow, rarely more than 160 km river navigable mileage, often shorter than this, therefore, the island's northern hinterland in the 80 s generation has previously closed state of primitive society for a long time,

Normal text: kalimantan island belongs to the tropical rain forest, most of the island is navigable rivers, an important lifeline for trade and business activity, often is the only lifeline, northern island is narrow, rarely more than 160 km river navigable mileage, often shorter than this, therefore, the island's northern hinterland in the 80 s generation had long-term closed state of primitive society,

CodePudding user response:

Transfer line column
Select * from (select name, nums from (select 1 id, 'apple' name, 1000
Nums FROM DUAL UNION ALL
SELECT id, 2 2000
'apple' name,Nums FROM DUAL UNION ALL
SELECT 3 id, 'apple' name, 4000
Nums FROM DUAL UNION ALL
SELECT id, 4 'orange' name, 5000
Nums FROM DUAL UNION ALL
SELECT 5 id, 'orange' name, 3000
Nums FROM DUAL UNION ALL
SELECT 6 id, 3500
'grapes' name,Nums FROM DUAL UNION ALL
7 id, SELECT 4200
'mango' name,Nums FROM DUAL UNION ALL
SELECT id, 5500
'mango' name,Nums FROM DUAL)) pivot (sum (nums) for the name in (' apple ', 'orange, orange, grape' ', 'mango mango));
Or
SELECT T.A LISTAGG (B, ', ') WITHIN GROUP (ORDER BY DESC B) FROM (
SELECT 1 A and 1 B FROM DUAL UNION ALL
SELECT 1 A, 2 B FROM DUAL UNION ALL
SELECT 2 A, 3 B FROM DUAL UNION ALL
SELECT 3 A, 4 B FROM DUAL UNION ALL
SELECT 3 A, 5 B FROM DUAL) T
GROUP BY T.A.

Biographies lines
Select id, name, jidu, xiaoshou from (select 1 id, 'apple' name, 1000 Q1, Q2 2000, 3300 in Q3, Q4 5000
The FROM DUAL UNION ALL
SELECT id, 2 'orange' name, 3000 Q1 and Q2 3000, 3200 Q3 and Q4 1500
The FROM DUAL UNION ALL
SELECT 3 id, a 'banana' name, 2500 Q1 and Q2 3500, 2200 Q3 and Q4 2500
The FROM DUAL UNION ALL
SELECT 4 id, 'grapes' name, 1500 Q1 and Q2 2500, 1200 Q3 and Q4 3500
The FROM DUAL) unpivot (xiaoshou jidu in (q1, q2, q3 and q4));

CodePudding user response:

http://www.itpub.net/thread-1017026-1-1.html
Ranks of transformation, there are instructions you want,

CodePudding user response:

http://www.itpub.net/thread-1017026-1-1.html
  • Related