Reputation: 39
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)));
I want to find the author of the book that has maximum sales.But it shows error. What's wrong with this?
Upvotes: 0
Views: 43
Reputation: 1
you should try this and if the problem will not solve then plz contact me
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 ) );
Upvotes: 0
Reputation: 2454
use alias after from clause
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
);
Upvotes: 0