Re: maximum of sums
Re: maximum of sums
От:
ThomasR <rehlich@wtal.de>
Дата:
Rob wrote: > Howdy all! > [snap table] > > I have this so far: > SQL> select > 2 max (sumamt) as maximum > 3 from > 4 (select > 5 sum (orders.quantity) as sumamt > 6 from > 7 orders > 8 group by > 9 orders.prod_no); > > MAXIMUM > --------- > 17 > > SQL> > > But how can I get the matching prod_id? perhaps with the limit-clause: select prod_no, sum( quantity ) as sumq from orders group by prod_no order by sumq desc limit 1 But it fails, if you have two or more products with the same amount of orders Thomas