Professional Documents
Culture Documents
Ejemplos de Procedimientos Almacenados de Northwind
Ejemplos de Procedimientos Almacenados de Northwind
'AverageCost' AS Cost_Sorted_By_Production_Days ,
[0], [5], [10], [15], [20],[25],[30]
FROM
(SELECT
ReorderLevel , unitprice
FROM [Products]
WHERE ReorderLevel = 5
)
AS SourceTable
PIVOT
(
AVG(unitprice)
FOR
ReorderLevel IN ([0], [5], [10], [15], [20],[25],[30])
) AS
PivotTable ;
SELECT CompanyName,P.UnitPrice
FROM Suppliers S
inner join Products P on P.SupplierID = s.SupplierID AND P.UnitPrice between 10 and 40
--where P.UnitPrice between 10 and 40
----Procedimiento almacenado
IF @i_operacion = 1
BEGIN
SELECT ProductName,C.CategoryName,ProductID,C.CategoryID
FROM Products P
INNER JOIN Categories C on C.CategoryID = P.CategoryID
WHERE ProductID = ISNULL(@i_product,ProductID)
AND P.CategoryID = ISNULL(@i_categoria,P.CategoryID)
END
END