此示例在带有 HAVING 的 Sphinx 中不起作用。我收到语法错误。 请解释一下,如何正确比较组?
SELECT someId from rt_index
GROUP BY someId
HAVING MIN(someId) != MAX(someId)
一般来说,您可以将“表达式”放入
select
子句中,然后可以在having
中使用它。
SELECT someId,MAX(otherId)-MIN(otherId) AS range FROM rt_index
GROUP BY someId
HAVING range != 0
我将其更改为使用
MAX(otherId)
,因为按someId
分组; MIN(someId)
始终匹配 MAX(someId)