Results 1 to 3 of 3

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User cecko19's Avatar
    Join Date: Jan:2011
    Location: Sofia
    Posts: 82

    !
    , :
    stored Northwind db, ( ). C#, stored , , record set.
    C# . stored . SQL , , . .
    Code:
    CREATE PROCEDURE sp_FindSupplierIncomes
    
    (@dateBegin DATETIME, 
    @dateEnd DATETIME,
    @supplierName nvarchar(50))
    
    AS
    BEGIN
    
    SELECT s.SupplierID
    FROM Suppliers s 
    	JOIN Products p ON
    	s.SupplierID = p.SupplierID
    DECLARE @unitsSum INT = p.UnitsOnOrder * p.UnitsOnOrder
    
    SELECT od.OrderID
    FROM OrderDetails od
    	JOIN Products p ON
    	p.ProductID = od.ProductID
    		JOIN Orders o ON
    		o.OrderID = od.OrderID
    		
    
    IF(@dateBegin > o.OrderDate AND @dateEnd < o.ShippedDate)
    	PRINT unitsSum
    END
    !

    .. SQL

  2. #2
    XaMaB's Avatar
    Join Date: Nov:2001
    Location:
    Posts: 20,387
    Code:
    CREATE PROCEDURE sp_FindSupplierIncomes
    
    (@dateBegin DATETIME, 
    @dateEnd DATETIME,
    @supplierName nvarchar(50))
    
    AS
    BEGIN
    
    SELECT s.SupplierID, sum(p.UnitsOnOrder * p.UnitsOnOrder)
    FROM Suppliers s 
    inner join Products p ON s.SupplierID = p.SupplierID
    inner join [Order Details] od ON 	p.ProductID = od.ProductID
    inner JOIN Orders o ON o.OrderID = od.OrderID
    where s.CompanyName like @supplierName
    and @dateBegin > o.OrderDate AND @dateEnd < o.ShippedDate
    group by s.supplierID
    
    
    END
    , .
    : XaMaB; . 0.42

    In God we Trust (all others must submit a X.509 certificate). , ()

  3. #3
    Registered User cecko19's Avatar
    Join Date: Jan:2011
    Location: Sofia
    Posts: 82
    !
    !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |