set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Create date: 2012-07-05
-- Description:	
-- =============================================
ALTER PROCEDURE [dbo].[usp_GetTransactionsByVendor]
	-- Add the parameters for the stored procedure here
	@startDT datetime = 0, 
	@endDT datetime = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT		v.Name as 'VendorsName', p.PartNum as 'ProductsPartNum',
				p.Description as 'ProductsDescription', p.PackageQty as 'ProductsPackageQty',
				t.Quantity as 'Quantity',
				p.Price as 'ProductsPrice', t.TransactionDT as 'TransactionsTransactionDT'
	FROM		Transactions t
					JOIN Products p on p.ProductNo = t.ProductNo
					JOIN Vendors v on v.VendorNo = p.VendorNo
	WHERE		t.TransactionDT >= @startDT AND t.TransactionDT <= @endDT
	GROUP BY	v.Name, p.PartNum, p.Description, p.PackageQty, t.Quantity, p.Price, t.TransactionDT
	ORDER BY	v.Name, t.TransactionDT
END


