mysql - SQL to produce desired output -


from data looks following (in mysql database):

mysql> select * test; +------------+--------+ | start      | name   | +------------+--------+ | 2013-04-01 | donald | | 2013-04-02 | daisy  | | 2013-04-03 | mickey | | 2013-04-03 | minnie | | 2013-04-01 | pluto  | | 2013-04-02 | goofy  | +------------+--------+ 6 rows in set (0.00 sec) 

i want write query produce output looks like:

2013-04-01  2013-04-02  2013-04003 ----------  ----------  ---------- donald      daisy       mickey pluto       goofy       minnie 

can suggest sql query produce output?

if helpful, code used create sample data.

create table test (     start date,     name varchar (20));  insert test values ('2013-04-01','donald'); insert test values ('2013-04-02','daisy'); insert test values ('2013-04-03','mickey'); insert test values ('2013-04-03','minnie'); insert test values ('2013-04-01','pluto'); insert test values ('2013-04-02','goofy');` 

going have have pivot table or series of case statements.

select        case when start = '2013-04-01' name end '2013-04-01',       case when start = '2013-04-02' name end '2013-04-02',       case when start = '2013-04-03' name end '2013-04-03' test; 

going little more difficult produce dynamically if table more complex. easier larger data exporting excel , using pivot table features.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -