PlamenYovchev Jul 15th, 2013 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROC usp_FindTotalIncome (@start_date INT,  @end_date INT, @company_name nvarchar(50))
  2. AS
  3. SELECT SUM(od.Quantity*od.UnitPrice) AS TotalIncome
  4. FROM Suppliers s
  5. INNER JOIN Products p
  6. ON s.SupplierID = p.SupplierID
  7. INNER JOIN [ORDER Details] od
  8. ON od.ProductID = p.ProductID
  9. INNER JOIN Orders o
  10. ON od.OrderID = o.OrderID
  11. WHERE s.CompanyName = @company_name AND (YEAR(o.OrderDate) >= @start_date AND YEAR(o.OrderDate) <= @end_date);
  12. GO
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand