(或 SLV 未定义)Informix 数据库
(or SLV is undefined) Informix data base
谁能帮我找出这个小查询中的错误。
select count(txno) as c1, rxno from mrgrxtxt
where c1>1
group by rxno;
错误:[Error Code: -217, SQL State: IX000] Column (c1) not found in any table in the query (or SLV is undefined).
如果我注释掉 WHERE 子句 (where c1 >1
),它执行得很好。
您不能在 where
中使用列别名。真的,你需要一个 having
子句。
试试这个:
select count(txno) as c1, rxno
from mrgrxtxt
group by rxno
having count(txno) > 1;
或者在派生的 table 中执行 GROUP BY
部分:
select c1, rxno
from
(
select count(txno) as c1, rxno
from mrgrxtxt
group by rxno
)
where c1 > 1;
比较复杂的聚合时非常方便。 (在复制或调整表达式时输入更少,出错的风险更小。)
谁能帮我找出这个小查询中的错误。
select count(txno) as c1, rxno from mrgrxtxt
where c1>1
group by rxno;
错误:[Error Code: -217, SQL State: IX000] Column (c1) not found in any table in the query (or SLV is undefined).
如果我注释掉 WHERE 子句 (where c1 >1
),它执行得很好。
您不能在 where
中使用列别名。真的,你需要一个 having
子句。
试试这个:
select count(txno) as c1, rxno
from mrgrxtxt
group by rxno
having count(txno) > 1;
或者在派生的 table 中执行 GROUP BY
部分:
select c1, rxno
from
(
select count(txno) as c1, rxno
from mrgrxtxt
group by rxno
)
where c1 > 1;
比较复杂的聚合时非常方便。 (在复制或调整表达式时输入更少,出错的风险更小。)