我的桌子:CREATE TABLE T(id INT PRIMARY KEY, value INT UNIQUE)
我认为该查询将在表中产生value
的中值。但是sqlite v.3.9.1给我no such column: ot.value
的行带来了错误group by
。尽管它使用类似的表达式,但它成功处理了where
行。查询有什么问题?
select
ot.id,
ot.value
from T as ot
where (
select count(c) > count(DISTINCT c) from (
select count(*) c from T as it
where it.value != ot.value
group by it.value < ot.value
) LessMore
)
同一查询在PostgreSQL中成功,并输出期望的结果。 MySQL给出错误Error Code: 1054. Unknown column 'ot.value' in 'where clause'