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)));

I want to find the author of the book that has maximum sales.But it shows error. What's wrong with this?

2 Answers2

0

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
                                          );
Ankit Agrawal
  • 2,426
  • 1
  • 13
  • 27
0

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 ) );