0

I have table with 3 columns , now how to transpose the data with single date_time

variables       date_time               value
gen_3       11-Jun-14 00:00:00          0.26
gen_3       11-Jun-14 00:00:01          0.59
gen_3       12-Aug-14 00:00:02          1.59
gen_3       12-Aug-14 00:00:04          3.59
gen_4       11-Jun-14 00:00:01          251.66
gen_4       11-Jun-14 00:00:02          156.42
gen_4       12-Aug-14 00:00:02          1198.42
gen_4       12-Aug-14 00:00:04          98.42
gen_3       12-Aug-14 00:00:03          Null(missing)
gen_4       12-Aug-14 00:00:03          Null(missing)

output should be

date_time             gen_3     gen_4
11-Jun-14 00:00:00    0.26   
11-Jun-14 00:00:01    0.59      251.66
11-Jun-14 00:00:02              156.42
12-Aug-14 00:00:02    1.59     1198.42
12-Aug-14 00:00:03      
12-Aug-14 00:00:04    3.59      98.42

Requesting to help, Thanks in advance.

Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
sam913
  • 43
  • 2
  • What is gen_3, gen_4? – Gouda Elalfy Dec 14 '15 at 06:19
  • hi @GE those are names in my variable column , thanks in advance – sam913 Dec 14 '15 at 06:24
  • 1
    Possible duplicate of [MySQL pivot table query with dynamic columns](http://stackoverflow.com/questions/12598120/mysql-pivot-table-query-with-dynamic-columns) – Shadow Dec 14 '15 at 06:50
  • This is called cross tabulated query or pivot table and has been answered several times on SO. – Shadow Dec 14 '15 at 06:52
  • Hi , in this case i have only one table – sam913 Dec 14 '15 at 07:04
  • The method described there is applicable to as many or as few tables as needed. The article linked there provides the theory behind it. In this form this question is a duplicate and I'm voting to close it. – Shadow Dec 14 '15 at 07:18

0 Answers0