Hello
I’m, trying to fill a grid with a pivot sql, using prepare stmt, but I can?t figure out how to put the sql statement in the sql section on the grid, can anyone shed some light?
SET @sql = (
SELECT GROUP_CONCAT(DISTINCT
CONCAT(
"sum(case when `idcatcxp`='", idcatcxp, "' then `monto` end) as `", `idcatcxp`, "`"
)
)
FROM cxp
);
SET @sql = CONCAT("select idvehiculo, ", @sql, " from cxp group by `idvehiculo`");
PREPARE stmt FROM @sql;
EXECUTE stmt;
If I try to save this inside the SQL section of the grid SC throws an error on saving.
thnx in advance!