问题来自https://github.com/roughike/flutter_facebook_login
我的解决方法是:
select seller_id
from (select seller_id, sum(price) price
from Sales
group by seller_id) S
# where S.price = max(S.price)
where S.price = (select max(price) from S)
但是,控制台会给我错误消息:
Table 'test.s' doesn't exist
我将最后一行代码替换为
where S.price = 0
这不会给我任何错误消息,这意味着S
表确实存在。所以我的问题是此错误消息是怎么来的?
答案 0 :(得分:2)
S
是对可用于限定列的表的引用。不能在FROM
子句中使用。
您可以使用CTE做您想做的事
with S as (
select seller_id, sum(price) as price
from Sales
group by seller_id
)
select seller_id
from S
where S.price = (select max(price) from S)