COUNT 在 PHP 的 db2 中导致错误
当我运行此查询时,出现以下错误:
Column MANUFACTURER or expression in SELECT list not valid.
如果删除 COUNT 函数,查询将正常运行。
有什么想法吗?
(此查询有点模拟,因此可能没有完全意义)
SELECT
MANUFACTURER
, PART_NUMBER
, COUNT(1) AS CNT
FROM
( SELECT
AWPART AS PART_NUMBER
, MANF AS MANUFACTURER
FROM STKMP
INNER JOIN PRICING AS P
ON AWPART = P.JCPART
AND R.CODE = 1
WHERE PART_NUMBER LIKE '%A2%') AS T
按如下方式修改最后一行会产生相同的效果。
WHERE PART_NUMBER LIKE '%A2%') AS T GROUP BY MANUFACTURER
When I run this query I get the following error:
Column MANUFACTURER or expression in SELECT list not valid.
The query runs fine if I remove the COUNT function.
Any ideas?
(this query is a bit of a mock so it might not make perfect sense)
SELECT
MANUFACTURER
, PART_NUMBER
, COUNT(1) AS CNT
FROM
( SELECT
AWPART AS PART_NUMBER
, MANF AS MANUFACTURER
FROM STKMP
INNER JOIN PRICING AS P
ON AWPART = P.JCPART
AND R.CODE = 1
WHERE PART_NUMBER LIKE '%A2%') AS T
Modifying the last line as follows produces the same effect.
WHERE PART_NUMBER LIKE '%A2%') AS T GROUP BY MANUFACTURER
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,只有当您有 GROUP BY 子句时,
COUNT()
才有意义。也许您想将其添加到末尾(在AST
之后?):Typically
COUNT()
is only meaningful if you have aGROUP BY
clause. Perhaps you meant to add this to the end (after theAS T
?):