我有以下 MySQL:
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'sum(case when perm = ''',
perm,
''' then 1 else 0 end) AS ',
perm
)
) INTO @sql
FROM perms;
SET @sql = CONCAT('SELECT role, ', @sql, '
FROM perms
GROUP BY role');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
但是,我必须使用 Sybase 12,有人知道如何转换吗?