Home > database >  For an SQL statement?? urgent
For an SQL statement?? urgent

Time:11-18

CodePudding user response:

https://blog.csdn.net/sinat_28984567/article/details/79853085

CodePudding user response:

Can pass a SQL to achieve?

CodePudding user response:

 

- 8.9.10.11.12.13.15.16.17.18, 23


The CREATE TABLE # A
(
A VARCHAR (10),
INT b,
C INT,
D int
)


# INSERT INTO A VALUES (a1, 1, 2, 3)
# INSERT INTO A VALUES (b1, 4 and 6)
# INSERT INTO A VALUES (c1, 7,8,9)
# INSERT INTO A VALUES (d1, 7,8,9)

SELECT * FROM # A
UNPIVOT
(
X FOR y in (b, c, d)
B)
The PIVOT
(
The SUM (x) FOR a IN ([a1], [b1], [c1], [] d1)
C)

DROP TABLE # A

  • Related