1
Answer

YTD Value in a query

Ramco Ramco

Ramco Ramco

3y
522
1

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)