Subject: | Re: Crosstab
| Date: | Fri, 20 Dec 2019 01:59:18 +1000
| From: | Bernie van't Hof <onrequest@somewhere>
| Newsgroups: | pnews.paradox-dos
|
FYI, I'd dreaded dealing with crosstabs but not too bad in the end with
some help from Mr Google.
Firstly run (chopped from php code):
SELECT
GROUP_CONCAT(
DISTINCT
CONCAT('{$type}(CASE WHEN `{$col2}` = ''', {$col2}, ''' THEN
{$col3} else 0 END) AS `', {$col2}, '`')
) AS `Stuff`
FROM `{$db}`.`{$tableName}`
Then stuff the result into:
SELECT `{$col1}`, {$Stuff} FROM `{$db}`.`{$tableName}` GROUP BY `{$col1}`
|