Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
*Procedimiento Almacenado
------------------------------------------------------------------------------------------*crea el procedimiento almacenado
create procedure ListadoProducto
as
begin
select p.ProductName, p.UnitPrice, p.UnitsInStock
from Products p;
end
*modifica el procedimiento almacenado
alter procedure ListadoProducto
as
begin
select p.ProductName, p.UnitPrice, p.UnitsInStock
from Products p
where p.UnitPrice > 20;
end
*seleccionar la maxima venta de un producto total
---------------------------------------------------select od.OrderID, od.ProductID, p.ProductName
from [Order Details] od, Products p
where od.ProductID = p.ProductID
group by od.OrderID, od.ProductID, p.ProductName
having MAX(od.Quantity*od.UnitPrice) in
(select MAX(do.Quantity*do.UnitPrice)
from [Order Details] do)
--------------------------------------------------------------------------select p.ProductName, odl.OrderID
from [Order Details] odl, Products p
where p.ProductID = odl.ProductID AND (odl.Quantity * odl.UnitPrice) IN
(select top 1 MAX(od.Quantity*od.UnitPrice) as Total
from [Order Details] od
group by od.OrderID
order by Total desc)
*La Maxima venta de los productos
--------------------------------select MAX(od.UnitPrice*od.Quantity)
from [Order Details] od