
27/09/2005, 13:32
|
| | Fecha de Ingreso: agosto-2005
Mensajes: 4
Antigüedad: 19 años, 5 meses Puntos: 0 | |
Gracias Claudio.
Finalmente pude solucionarlo asi:
select p.productId, p.productname, sum(od.unitprice*od.quantity) as Monto
from products p inner join order_details od on (p.productID=od.productID) inner join orders o on (o.orderID=od.OrderID)
where year(o.orderdate)=1998
group by p.productID
having monto > (select sum(od1.unitprice*od1.quantity) as Monto1
from products p1 inner join order_details od1 on (p1.productID=od1.productID) inner join orders o1 on (o1.orderID=od1.OrderID)
where (year(o1.orderdate)=1997 And p.ProductId=p1.ProductId)
group by p1.productID)
Saludos... |