select a.author_id,a.name,a.city,a.country from author a,catalog c
where c.author_id=a.author_id
and c.book_id=(select book_id from order_details
group by book_id
having sum(quantity)=(select max(quantity)
from (select sum(quantity) as quantity from order_details group by book_id)));
我想找到最大销量的书的作者。但它显示错误。这有什么问题?
答案 0 :(得分:0)
在子句
之后使用别名select a.author_id,a.name,a.city,a.country
from author a,
catalog c
where c.author_id=a.author_id
and c.book_id=(select book_id
from order_details
group by book_id
having sum(quantity)=(select max(quantity)
from (select sum(quantity) as
quantity
from order_details
group by book_id)
)a
);
答案 1 :(得分:0)
你应该尝试这个,如果问题无法解决,请联系我
select a.author_id,a.name,a.city,a.country
from author a,catalog c
where c.author_id=a.author_id
and c.book_id=(select book_id
from order_details d
group by d.book_id
having sum(quantity)=(select max(e.quantity )
from (select sum(dd.quantity) as quantity
from order_details dd
group by dd.book_id) as e ) );