0

Hello i work on phpmyadmin and i don't have the command PIVOT. I just want a command for display a table like that

The origin table

SIGMA TARIF VOL
58 T3 45
58 T4 89
58 T5 88
58 T6 99
58 T7 1
59 T3 400
59 T4 900

SIGMA AND TARIF ARE INDEXED like a primary key

I have like 197 differents TARIF and 40,000 SIGMA

I want display the table like that

SIGMA T3 T4 T5 T6 T7
58 45 89 88 99 1
59 400 500 ETC ETC ETC

Thanks you ;)

1 Answers1

0

I succed....

  GROUP_CONCAT(DISTINCT
    CONCAT(
      'max(case when TARIF = ''',
      TARIF,
      ''' then VOL1AN end) ',
      TARIF
    )
  ) INTO @sql 
FROM
  direction_prix_volumes.volumes1an_tarif_proxi;
SET @sql = CONCAT('SELECT SIGMA, ', @sql, ' 
                  FROM direction_prix_volumes.volumes1an_tarif_proxi 
                   GROUP BY SIGMA');

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;````