I have the following stored procedure:
ALTER PROCEDURE [dbo].[Cash_
-- Add the parameters for the stored procedure here
@BeginDate datetime,
@EndDate datetime ,
@Division varchar(50)
AS
SET NOCOUNT ON;
SELECT
giftid,giftacctno,giftacctdv,
giftkey,gifttype,gifteffdat,giftjntamt,giftamount
from gifts
WHERE (gifttype ='b' oR gifttype ='g' OR gifttype ='y')
and (gifteffdat>=@BeginDate AND gifteffdat<=@EndDate)
and giftacctdv = @Division
This allows me to obtain a report based on a date range (ie 7/1/09 through 7/31/09). Now I want an indicator if it is the first time the person has given based on the date being less than the begin date and the division. For example if a person did not give anything to Division #41 prior to 7/1/09 there should be an indicator of 'Y'. How could I accomplish this. I am thinking there can be a max(case statement or similar)
ALTER PROCEDURE [dbo].[Cash_
-- Add the parameters for the stored procedure here
@BeginDate datetime,
@EndDate datetime ,
@Division varchar(50)
AS
SET NOCOUNT ON;
SELECT
giftid,giftacctno,giftacctdv,
giftkey,gifttype,gifteffdat,giftjntamt,giftamount
from gifts
WHERE (gifttype ='b' oR gifttype ='g' OR gifttype ='y')
and (gifteffdat>=@BeginDate AND gifteffdat<=@EndDate)
and giftacctdv = @Division
This allows me to obtain a report based on a date range (ie 7/1/09 through 7/31/09). Now I want an indicator if it is the first time the person has given based on the date being less than the begin date and the division. For example if a person did not give anything to Division #41 prior to 7/1/09 there should be an indicator of 'Y'. How could I accomplish this. I am thinking there can be a max(case statement or similar)