UFN_CONSTITUENTMATCH_MIDDLENAMESCOREDEDUCTION_BYRESULT

Return

Return Type
table

Parameters

Parameter Parameter Type Mode Description
@MIDDLENAMERESULT tinyint IN
@FIRSTNAMERESULT tinyint IN

Definition

Copy


            create function dbo.UFN_CONSTITUENTMATCH_MIDDLENAMESCOREDEDUCTION_BYRESULT (
                @MIDDLENAMERESULT tinyint,
                @FIRSTNAMERESULT tinyint
            )
            returns table -- Writing as in-line table for performance vs scalar function

            with schemabinding
            as return
                -- non-match first names are significant enough to disqualify completely

                -- spouses could have everything the same except first name

                select
                    case @MIDDLENAMERESULT
                        when 0 then case 
                            @FIRSTNAMERESULT 
                                when 1 then -2 
                                when 2 then -5 
                                when 3 then -5 
                                when 5 then -1 
                                when 6 then -1 
                                else 0 
                            end
                        when 1 then 
                            case @FIRSTNAMERESULT 
                                when 1 then -1 
                                when 2 then -2 
                                when 3 then -2 
                                when 5 then 0 
                                when 6 then 0 
                                else 1 
                            end
                        when 2 then 6 
                        when 3 then 16 
                        else 0 
                    end as DEDUCTION;