mysql - How can I aggregate data from multiple rows into a single one spread across multiple columns? -
i have table in database , want aggregate data multiple rows single 1 spread across multiple columns:
id pid date time 1 12 10/04/2014 7:00 2 12 10/04/2014 10:00 3 12 10/04/2014 15:00 4 13 10/04/2014 7:00 5 13 10/04/2014 15:00 6 12 11/04/2014 7:20 7 12 11/04/2014 15:10 8 13 11/04/2014 7:10 9 13 11/04/2014 7:50 10 13 11/04/2014 15:00 11 13 11/04/2014 15:50
pid employee id, specific it's attendance system. need extract format , insert form in table:
id pid date time1 time2 time3 time4 1 12 10/04/2014 7:00 10:00 15:00 2 13 10/04/2014 7:00 15:00 3 12 11/04/2014 7:20 15:10 4 13 11/04/2014 7:10 7:50 15:00 15:50
while concerns stated in comments valid, i'll assume have reason specific requirement.
this solution work mssql:
this solution work mysql:
Comments
Post a Comment