简体   繁体   中英

Can I add a custom row to MySQL pivot Query that is another pivot?

I have a crosstab query, that displays results in such a way

      user1 user2 user3 ...etc
date1 val11 val12 val13 ... 
date2 val21 val22 val23 ... 
date3 val31 val32 val33 ... 
...
etc

Thing is users have a rank field.

I was wandering if I could insert it like so using MySQL:

      user1 user2 user3 ...etc
rank  rank1 rank2 rank3
date1 val11 val12 val13 ... 
date2 val21 val22 val23 ... 
date3 val31 val32 val33 ... 
...
etc

The application is a php webapp and the final product is an excel spreadsheet. If it cannot be done through a query I would try and add it on conversion of the query results to the excel.

Any help is appreciated.

THe solution would be to have a rank crosstab query ant date-value crosstab query and have a union of each. All columns have to match though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM