我通过 iSql 使用 Informix 版本 11.50.FC6
我给CASE
块的结果一个虚拟名称,att_hrs
SELECT c.id,
CASE WHEN ( c.prog = 'UNDG'
AND (c.grd IN (SELECT DISTINCT grd FROM grd_table WHERE att_fctr = 1) OR (c.grd IN ('TR','W','LAB','WC')))
AND c.grd NOT IN ('WM')
AND c.stat NOT IN ('X','D'))
THEN CAST(SUM(c.hrs) AS CHAR(4))
ELSE 'ELSED (att)'
END att_hrs
FROM cw_rec c
WHERE c.id IN (SELECT DISTINCT id FROM stu_ids)
GROUP BY c.id
INTO TEMP cheese
WITH NO LOG;
这给了我一个错误:
294: The column (att_hrs) must be in the GROUP BY list.
尝试按照建议修复错误:
SELECT c.id,
CASE WHEN ( c.prog = 'UNDG'
AND (c.grd IN (SELECT DISTINCT grd FROM grd_table WHERE att_fctr = 1) OR (c.grd IN ('TR','W','LAB','WC')))
AND c.grd NOT IN ('WM')
AND c.stat NOT IN ('X','D'))
THEN CAST(SUM(c.hrs) AS CHAR(4))
ELSE 'ELSED (att)'
END att_hrs
FROM cw_rec c
WHERE c.id IN (SELECT DISTINCT id FROM stu_ids)
GROUP BY c.id,
att_hrs
INTO TEMP cheese
WITH NO LOG;
然后给我这个错误:
217: Column (att_hrs) not found in any table in the query (or SLV is undefined).
att_hrs
不在聚会上的时候他们很容易找到GROUP BY
,但现在突然之间,att_hrs
迷失在了酱汁中……
你能解决这个问题吗?
真正的错误是什么&| 解决这里发生的事情以及我需要做些什么来解决它?
编辑
我尝试了 RET 的解决方案
GROUP BY 1,2,3...
并得到以下错误:
321: Cannot group by aggregate column.