Z
Z
z_o_r_k2017-04-13 02:39:50
MySQL
z_o_r_k, 2017-04-13 02:39:50

Is a pivot table possible in mysql?

Hello!
Straight to the point, no preludes.
Database. It has a note to the workers. The program visualizes the record/schedule/schedule of employees.
With a simple query, I get this result:

Query result example
8f6cf445a74440ac9deb34f4aee2810c

Is it possible to get something similar?
Desired response from the DB
2e44f68cf3a1420599251aa3a8797e02

As a result, the program will look something like this:
only prettier
b78e5ab768ed4bed9986e23ec318d4c8

In any case, I can collect this in the program, but I want to get the maximum already in the response from the database.
I put it in Excel simply because it's faster. mysql database, IDE VS2015, C# language.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-04-13
@Rsa97

It will not be possible to automatically obtain the desired table with an arbitrary number of employees. You can either list all workers in the request, as PrAw wrote , or get lists of workers by time and parse them already on the client.

SELECT `time`, GROUP_CONCAT(`worker`) 
  FROM `table`
  GROUP BY `time`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question