UFN_TRANSLATIONTABLEGRADE_RANGEGAPS

Check that there are no gaps between numeric grade ranges.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@TRANSLATIONTABLEID uniqueidentifier IN

Definition

Copy


            create function dbo.UFN_TRANSLATIONTABLEGRADE_RANGEGAPS
                (
                    @TRANSLATIONTABLEID uniqueidentifier
                )
            returns bit
            as begin
                -- Assume no gaps

                declare @RETVAL int = 0;

                if (exists (select *
                            from dbo.TRANSLATIONTABLEGRADE ttg
                                left outer join dbo.TRANSLATIONTABLEGRADE ttg2 on ttg.TRANSLATIONTABLEID = ttg2.TRANSLATIONTABLEID
                            where ttg.TRANSLATIONTABLEID = @TRANSLATIONTABLEID
                                --ttg2 should be the next row down when ordered by HighestScore

                                and ttg2.HIGHESTSCORE = (select max(HIGHESTSCORE) from dbo.TRANSLATIONTABLEGRADE ttg3
                                                         where ttg3.TRANSLATIONTABLEID = ttg.TRANSLATIONTABLEID
                                                            and ttg3.HIGHESTSCORE < ttg.HIGHESTSCORE)
                                and (ttg.LOWESTSCORE - ttg2.HIGHESTSCORE > .01)
                    ))
                    set @RETVAL = 1;

                return @RETVAL;
            end