CREATE OR ALTER FUNCTION dbo.LEAST_NUMERIC205(
    @a NUMERIC(20,5),
    @b NUMERIC(20,5)
)
RETURNS NUMERIC(20,5)
AS
BEGIN
    RETURN CASE 
        WHEN @a IS NULL THEN @b
        WHEN @b IS NULL THEN @a
        WHEN @a < @b THEN @a ELSE @b
    END
END

CREATE OR ALTER FUNCTION dbo.GREATEST_NUMERIC205(
    @a NUMERIC(20,5),
    @b NUMERIC(20,5)
)
RETURNS NUMERIC(20,5)
AS
BEGIN
    RETURN CASE 
        WHEN @a IS NULL THEN @b
        WHEN @b IS NULL THEN @a
        WHEN @a > @b THEN @a ELSE @b
    END
END