我有一个程序,我需要每次在另一个查询中检查当前值
SET @sql = NULL;
set @ct=(select count(alloc_hrs) from emp_sample where week(alloc_date)=<current_value>);
SET SESSION group_concat_max_len = 1000000;
SELECT GROUP_CONCAT(DISTINCT
(CONCAT ('MAX(CASE WHEN alloc_date=''',
alloc_date,
''' THEN @ct END) `',
year(alloc_date),week(alloc_date),
'week`'
))
)
INTO @sql
FROM emp_sample;
SET @sql = CONCAT('SELECT emp_code, ', @sql,' FROM emp_sample group by emp_code');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
在mysql
如果不是我应该替换什么