Transformation of records 1 column 3 row -> 1 row 3 column
- by Nehal Rupani
First look at below query
SELECT count(id) as total_record,
id, modeller, MONTHNAME(completed_date) as current_month,
Quarter(completed_date) as current_quarter, Difficulty,
YEAR(completed_date) as current_year
FROM model
WHERE modeller != ''
AND completed_date BETWEEN '2010-04-01' AND '2010-05-31'
AND Difficulty != ''
Group by Difficulty,
Month(completed_date)
Order by Month(completed_date) ASC
Results I am getting is
Modeller Month Year Difficulty
-------------------------------------
XYZ Jan 2010 23
XYZ Jan 2010 14
XYZ Jan 2010 15
ABC Feb 2010 5
ABC Feb 2010 14
ABC Feb 2010 6
I want result like
Modeller Month Year Difficulty
--------------------------------------
XYZ Jan 2010 23, 14, 15
ABC Feb 2010 5, 14, 6
My database is Mysql for application i am developing so any help would be greatly appericated.