1

my query:

 SELECT ID, assiduos_a1, assiduos_a2, max(date)
   FROM cli_agendados_assiduos
  WHERE ID = 10357410;

which returns:

id          assiduos_a1 assiduos_a2 max(date)
10357410    337         508         08/01/2015 14:54:48

but I need the result in rows, like this:

Label       Value   id          max(date)
assiduos_a1 337     10357410    08/01/2015 14:54
assiduos_a2 508     10357410    08/01/2015 14:54

only in this format my graph (pie chart google) works correctly!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Samuel Dias
  • 13
  • 1
  • 4
  • can you show the inpu data? – Jens Feb 06 '15 at 12:07
  • 1
    possible duplicate of [Mysql query to dynamically convert rows to columns](http://stackoverflow.com/questions/14834290/mysql-query-to-dynamically-convert-rows-to-columns) – Venkata Krishna Feb 06 '15 at 12:08
  • possible duplicate of [Converting Columns into rows with their respective data in sql server](http://stackoverflow.com/questions/5337380/converting-columns-into-rows-with-their-respective-data-in-sql-server) – display name Feb 06 '15 at 12:21

1 Answers1

1

You can use union all:

SELECT 'assiduos_a1', assiduos_a1 as value, id, max(date)
FROM cli_agendados_assiduos
WHERE ID = 10357410
UNION ALL
SELECT 'assiduos_a2', assiduos_a2 as value, id, max(date)
FROM cli_agendados_assiduos
WHERE ID = 10357410;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786