我有一个这样的sql查询:
select tt.product_name, tt.countt
from (select ofr.product_name as product_name, count(*) as countt
from offers ofr
group by ofr.product_name) as tt
where 12 = (select max(tt.countt) from tt);
我的问题在最后一行:sql 无法识别表 tt!
正如我在 SQL/92 中所知道的那样,表的这种用法是有效的。但我不知道在以后的版本中应该使用什么替代方案。
我正在使用这个版本的 MY-SQL:
mysql Ver 14.14 Distrib 5.7.25,适用于使用 EditLine 包装器的 Linux (x86_64)
更新:我希望 tt 中“countt”的行是 tt 中所有行中的最大值。数字“12”是一个例子,因为根据我数据库中的数据,“count”列的最大值将为 12