Hi All,
It feels so good to be back on Bytes after almsot 2-3 years.. anyways here is my quesion. I would like to transpose my query output.
here are the details..
*** Tables
GDCA
gdcid,gdcid,gda id,age
GDA
gdaid,name
*** Queries
SELECT
gda.id,age
FROM
gdca
JOIN gda ON (gda.id = gdca.gdaid)
WHERE gdca.gdcid IN(3573,184)
ORDER BY gdca.id
*** Output
"id" "age"
"1" "0"
"1" "11"
"2" "0"
"2" "30"
"3" "0"
"3" "1"
"4" "0"
"4" "1"
"5" "0"
"5" "1"
*** I want it something like
1 2 3 4 5
0 0 0 0 0
11 30 0 0 0
I tried using IF() clause or even CONCAT and then SUBSTRING_INDEX , however not getting the required output.
Any pointer is appreciated.
Thanks and Regards,
RP
It feels so good to be back on Bytes after almsot 2-3 years.. anyways here is my quesion. I would like to transpose my query output.
here are the details..
*** Tables
GDCA
gdcid,gdcid,gda id,age
GDA
gdaid,name
*** Queries
SELECT
gda.id,age
FROM
gdca
JOIN gda ON (gda.id = gdca.gdaid)
WHERE gdca.gdcid IN(3573,184)
ORDER BY gdca.id
*** Output
"id" "age"
"1" "0"
"1" "11"
"2" "0"
"2" "30"
"3" "0"
"3" "1"
"4" "0"
"4" "1"
"5" "0"
"5" "1"
*** I want it something like
1 2 3 4 5
0 0 0 0 0
11 30 0 0 0
I tried using IF() clause or even CONCAT and then SUBSTRING_INDEX , however not getting the required output.
Any pointer is appreciated.
Thanks and Regards,
RP
Comment