User Tools

Site Tools


software:mysq:pivots

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
software:mysq:pivots [2020/11/12 07:34] – created rodolicosoftware:mysq:pivots [2020/11/12 07:37] rodolico
Line 1: Line 1:
 ====== Create a pivot result in mariadb/mysql ====== ====== Create a pivot result in mariadb/mysql ======
  
-This relies heavily on [[https://stackoverflow.com/questions/15997090/crosstab-view-in-mysql]] and I even stole his/her data structure. I just worked to figure out what was going on, then wrote this up.+This relies heavily on [[https://stackoverflow.com/questions/15997090/crosstab-view-in-mysql]] and I even stole the data structure. I just worked to figure out what was going on, then wrote this up. NOTE: it is possible I made a mistake in my interpretation. If so, it is all on me.
  
-A pivot query (aka crosstab) is a type of query where the top, where you normally have column names, is the result of the query. Take this data structure (stolen from Taryn's answer).+A pivot query (aka crosstab) is a type of query where the top, where you normally have column names, is the result of the query. Some database engines have a special //PIVOT// function built in for this, but MySQL/MariaDB is not one of them. 
 + 
 +Take this data structure (stolen from Taryn's answer in the above article).
  
 <code sql create_test.sql> <code sql create_test.sql>
Line 36: Line 38:
 </code> </code>
  
-A simple query to find everyone's score for a certain playdate would be+A simple query to find everyone'total score summarized by playdate would be
  
 <code sql> <code sql>