Home > database >  How mysql statistics to link all the value that corresponds to a field in the table data record numb
How mysql statistics to link all the value that corresponds to a field in the table data record numb

Time:09-30

Described as shown in figure, the title is not very clear, in a list is the first of a field, and other fields are all the other all the values of a field in a table, now want to get like this through the query results,

CodePudding user response:

CodePudding user response:

Select month, sum (case when B.x xx='collision' then 1 end), sum (case when B.x xx='tipping' then 1 end),
The from TB A, TB B
Where A.x x=B.x x
Group by month
  • Related