need help in my SP, its not give the req output.

  • Hello everyone,i m using SQL Server 2000, here is my SP that returns the items of Distributors last 7 days including currentdate but my SP not giving me the right solution

    as, in this i called a function, in that function its reuturns the sum of Qunatity solde at each days of last seven days. plz help me whats wrong with this, how i get the data of last seven days as ([today: friday] 27,26,25,24,23,22,21

    CREATE PROCEDURE [dbo].[Distributor_Last7DaysSolds]

    @DistributorID [int],

    @StatusID      [int]

    AS

    SELECT distinct dbo.BuyerItems.ItemID,dbo.BuyerItems.Quanity,dbo.BuyerItems.SoldDate ,DATENAME(dw ,soldDate) as Days, dbo.GetSoldCountInOneDay(dbo.BuyerItems.SoldDate) as TotalSolds

    FROM     dbo.BuyerItems INNER JOIN

             dbo.Item ON dbo.BuyerItems.ItemID = dbo.Item.ItemID

    where  (dbo.Item.DistributorID=@DistributorID) and  (dbo.BuyerItems.ItemStatusID=@StatusID)

    and (datediff(dd,SoldDate,GetDate()-7) < 7)

    plz reply me. Thanx in Advance.

  • CREATE PROCEDURE [dbo].[Distributor_Last7DaysSolds]

    @DistributorID [int],

    @StatusID      [int]

    AS

    SELECT distinct dbo.BuyerItems.ItemID,dbo.BuyerItems.Quanity,dbo.BuyerItems.SoldDate ,DATENAME(dw ,soldDate) as Days, dbo.GetSoldCountInOneDay(dbo.BuyerItems.SoldDate) as TotalSolds

    FROM     dbo.BuyerItems INNER JOIN

             dbo.Item ON dbo.BuyerItems.ItemID = dbo.Item.ItemID

    where  (dbo.Item.DistributorID=@DistributorID) and  (dbo.BuyerItems.ItemStatusID=@StatusID)

    and (datediff(dd,SoldDate,GetDate()) < 7)

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply