Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 515.6k

YTD Value in a query

Aug 17 2021 2:22 AM

Hi

  I have below Stored Procedure . I want YTd column value also.

If user enters @frDate = 01/01/2021 and @toDate = 31/01/2021 then YTD value should be from 01/04/2020 to 31/01/2021

If user enters @frDate = 01/12/2020 and @toDate = 31/12/2020 then YTD value should be from 01/04/2020 to 31/12/2020

Create PROCEDURE [dbo].[SpBpGroupWiseSalePurchase]
    @frDate date,
    @toDate date,
    @CType nvarchar(1)
AS
BEGIN
        SELECT code,name
        (Select sum(INvTotal) from Invoice where dt between @frDate and @ToDate ) as "Total Sales"
        from InvoiceHeader T0

End

Thanks


Answers (1)