I have a data format like this:
+ ---- + - ------ + --------------------- + | ID | Utente | Data | + ---- + -------- + --------------------- + | 1 | Man 1 | 2014-02-10 12:12:00 | + ---- + -------- + --------------------- + | 2 | Female 1 | 2015-02-10 12:12:00 | + ---- + -------- + --------------------- + | 3 | Man 2 | 2016-02-10 12:12:00 | + ---- + -------- + --------------------- + | 4 | Female 1 | 2014-03-10 12:12:00 | + ---- + -------- + --------------------- + | 5 | Man 1 | 2014-04-10 12:12:00 | + ---- + -------- + --------------------- + | 6 | Female 1 | 2014-02-10 12:12:00 | + ---- + -------- + --------------------- +
I want To create a report that organizes external ways in this way:
+ --------- + -------- + ---- --- + --------------------- + --------------------- + - ------------------- + | ID | Utente | Counting | Data 1 Data2 Data 3 + --------- + -------- + ------- + --------------------- + --------------------- + --------------------- + | 1, 5. Man 1 | 2 | 2014-02-10 12:12:00 | 2014-04-10 12:12:00 | | + --------- + -------- + ------- + --------------------- + --------------------- + --------------------- + | 2, 4, 6 female 1 | 3 | 2015-02-10 12:12:00 | 2014-03-10 12:12:00 | 2014-05-10 12:12:00 | + --------- + -------- + ------- + --------------------- + --------------------- + --------------------- +
All rows include the same user (uentte) at the same time, all dates and records in a row will be included with counting. Thank you
It is definitely possible to write a query, which gives data in the format you want, So I recommend that you query the GROUP and use two functions:
Select GROUP_CONCAT (ID) ID, utente, COUNT (*) as CNT, GROUP_CONCAT (data base DATA) DATA FROM TABLENEME GROUP BY utente
Then at the application level, you can split your Dates fields into several columns.
No comments:
Post a Comment