0
Hi, I know there are some similar questions here already, but none of them helped me. I have the following table in my database:
+----------+---------------+--------+
| id_bolao | data_concurso | premio |
+----------+---------------+--------+
| 1 | 2019-05-18 | 1 |
| 1 | 2019-05-18 | 10 |
| 1 | 2019-05-18 | 22 |
| 1 | 2019-05-18 | 45 |
| 1 | 2019-05-18 | 70 |
| 1 | 2019-05-19 | 3 |
| 1 | 2019-05-19 | 4 |
| 1 | 2019-05-19 | 47 |
| 1 | 2019-05-19 | 34 |
| 1 | 2019-05-19 | 80 |
+----------+---------------+--------+
And I need to arrive at the following result, but these values are not fixed. every day will be registered new contests with 5 different awards:
+--------+---------------+---------+---------+---------+---------+---------+
|id_bolao| data_concurso | premio1 | premio2 | premio3 | premio4 | premio5 |
+--------+---------------+---------+---------+---------+---------+---------+
| 1 | 2019-05-18 | 1 | 10 | 22 | 45 | 70 |
| 1 | 2019-05-19 | 3 | 4 | 47 | 34 | 80 |
+--------+---------------+---------+---------+---------+---------+---------+
The questions already existing in the community give solutions with constant values and not dynamic values. Any idea?
Before anything, start by doing the tour to understand how the community works; then read the How to ask to check how you can improve your question and finally access help center to check various articles that will help you better understand the site.
– Gustavo André Richter
I already read the tour friend, and I believe the question is very clear! Thank you
– nicolasz
Possible duplicate of PIVOT - Group Duplicate Records in a Single Line
– Sorack
Related: PIVOT - SELECT reversing row and column.
– Sorack
What version of
MySQL
?– Sorack
The system will work as follows, every day will be registered new contests with 5 different prizes, but when showing the query on the screen would not like to show in several lines the prizes of the same contest, but rather all prizes in the same line, as the example.
– nicolasz
Version of Mysql 5.7
– nicolasz