Home > database >  According to the statistical problems
According to the statistical problems

Time:10-10

Have a table, what is need to statistics of the different types of work order number and problem is that the type is dynamic, in some more, some less, in about 30 or so:

Table is as follows:
Working type work order number
01 how a02 b000001
01 c01 b000002
03 c01 b000003
01 how a02 b000004
01 b05 b000005
02 c01 b000006
.
After the summary is as follows:

Working how a02 b05 c01
01 2 1 1
02 1
03 1

Plans to use the PIVOT, but if not, because the type is dynamic, and more,

thank you

CodePudding user response:

Can only use dynamic statement, Mr Into statements, execute it again,

CodePudding user response:

Staff will have any changes, if not, can not swap rows and columns,

CodePudding user response:

Personnel and the type is dynamic,

CodePudding user response:

reference 1st floor selling fruit net reply:
can only use dynamic statement, Mr Into statements, then execute it,


What do you mean?

CodePudding user response:

SELECT * FROM tongji PIVOT (count (order number) FOR type in (SELECT type FROM tongji))

See online have similar this kind of statistical method, but cannot run through, don't know what to get,

CodePudding user response:

reference 5 floor dbcz444 reply:
SELECT * FROM tongji PIVOT (count (order number) FOR type in (SELECT type FROM tongji))

See online have similar this kind of statistical method, but you can't run, don't know how to get it,


In type (select from tongji) into a dynamic statement joining together here
  • Related