UFN_CHARITYCLAIMREFERENCENUMBER_SAMEWAITINGPERIOD

Returns true if all entries in the charity claim reference number table with the same reference number have the same waiting period.

Return

Return Type
bit

Definition

Copy


            create function dbo.UFN_CHARITYCLAIMREFERENCENUMBER_SAMEWAITINGPERIOD()
            returns bit
            with execute as caller
            as begin
                declare @COUNT int;

                select @COUNT = max(PAIRCOUNT) from
                    (select count(REFERENCENUMBER) PAIRCOUNT from
                        (select distinct REFERENCENUMBER, WAITINGPERIOD from dbo.CHARITYCLAIMREFERENCENUMBER group by REFERENCENUMBER, WAITINGPERIOD) PAIRS
                    group by REFERENCENUMBER) PAIRCOUNTS

                if @COUNT > 1 
                    return 0;

                return 1;
            end