SQL Server Scaler Function Calculation

In the function below if the @IndemPaid is = 0.00 or below  then answer should be 0.00 (Stop Calculation)
Else Proceed

I have no idea how to code for this. Thanks



USE [ExportPahpixTest]
GO
/****** Object:  UserDefinedFunction [dbo].[GetIndemHPIXPaidCeded]    Script Date: 09/26/2013 10:59:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/********************************************************************************************************
                                                      GetIndemHPIXPaidCeded
                  
      Created      MJB      09/24/2013
            Gets the Indemnity HPIX Paid Ceded calculation for the Loss Run

*********************************************************************************************************/
ALTER FUNCTION [dbo].[GetIndemHPIXPaidCeded]
    (
      @TreatyNo VARCHAR(12) ,
      @IndemPaid NUMERIC(12, 2) ,
      @Claim AS VARCHAR(20)
    )
RETURNS NUMERIC(12, 2)
AS
    BEGIN
        RETURN (
    SELECT ISNULL(CAST((@IndemPaid - t.Claims_Retention) * t.Treaty_Claims_PCT/100 AS NUMERIC(12, 2)), 0.00)
    FROM dbo.Treaty t
    WHERE
        t.TreatyKey = @TreatyNo AND
        t.State = LEFT(@Claim, 1)
    )
    END
mburk1968Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
ALTER FUNCTION [dbo].[GetIndemHPIXPaidCeded]
    (
      @TreatyNo VARCHAR(12) ,
      @IndemPaid NUMERIC(12, 2) ,
      @Claim AS VARCHAR(20)
    )
RETURNS NUMERIC(12, 2)
AS
    BEGIN

   IF @IndemPaid <= 0
   BEGIN
      RETURN 0.0
   END

        RETURN (
    SELECT ISNULL(CAST((@IndemPaid - t.Claims_Retention) * t.Treaty_Claims_PCT/100 AS NUMERIC(12, 2)), 0.00)
    FROM dbo.Treaty t
    WHERE
        t.TreatyKey = @TreatyNo AND
        t.State = LEFT(@Claim, 1)
    )
    END
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott PletcherSenior DBACommented:
ALTER FUNCTION [dbo].[GetIndemHPIXPaidCeded]
    (
      @TreatyNo VARCHAR(12) ,
      @IndemPaid NUMERIC(12, 2) ,
      @Claim AS VARCHAR(20)
    )
RETURNS NUMERIC(12, 2)
AS
    BEGIN
        RETURN (
    SELECT CASE WHEN @IndemPaid = 0.00 THEN 0.00
    ELSE (
    SELECT ISNULL(CAST((@IndemPaid - t.Claims_Retention) * t.Treaty_Claims_PCT/100 AS NUMERIC(12, 2)), 0.00)
    FROM dbo.Treaty t
    WHERE
        t.TreatyKey = @TreatyNo AND
        t.State = LEFT(@Claim, 1)
    ) END --CASE
    )
    END --FUNCTION
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.