new to cusrors still cant get 1st right

  • USE [Adamtest2005DB]

    GO

    /****** Object: Table [dbo].[tblPolicys] Script Date: 07/31/2009 08:50:06 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TABLE [dbo].[tblPolicys](

    [Policy_No] [int] IDENTITY(1,1) NOT NULL,

    [Home_Coverage] [money] NOT NULL,

    [HomePremium] [money] NOT NULL,

    [Personal_Prop_Coverage] [money] NOT NULL,

    [Personal_Prop_Premium] [money] NOT NULL,

    CONSTRAINT [PK_tblPolicys] PRIMARY KEY CLUSTERED

    (

    [Policy_No] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO --insert 2 rows for testing

    INSERT INTO tblPolicys

    ([Home_Coverage]

    ,[HomePremium]

    ,[Personal_Prop_Coverage]

    ,[Personal_Prop_Premium])

    VALUES

    (300000.0000

    ,800.0000

    ,50000.0000

    ,50.0000)

    INSERT INTO tblPolicys

    ([Home_Coverage]

    ,[HomePremium]

    ,[Personal_Prop_Coverage]

    ,[Personal_Prop_Premium])

    VALUES

    (5000000.0000

    ,1000.0000

    ,100000.0000

    ,100.0000)

    --------------------------

    --has to be done in a cursor if some one can also show me a reord base way as well great. but

    --I was told flat out to do it as a cursor.

    --need to get to records per policy number based on

    --if they baded the preimium for peronal_property, if it is left 0 then only 1 rows show come up on the seclect.

    --condition 2 is that the 2 Coverages are divided by their respective rate and put into

    --a qry made field I.e.

    --Personal_Prop_Coverage / Personal_Prop_Premium AS Personal_Prop_Rate

    --what we r trying 2 get our results to look like, i.e. Output from a selecting cursor:

    Policy ID Home_Cov HomePrem Personal_Prop_Cove Personal_Prop_Premi Home_Cov_Rate Personal_Prop_Rate

    1 300000 800 50000 50 (a computed Number)

    1 300000 800 50000 50 (a computed Number)

  • can you elaborate on this part? I don't understand the business rules:

    need to get to records per policy number based on

    --if they baded the preimium for peronal_property, if it is left 0 then only 1 rows show come up on the seclect.

    --condition 2 is that the 2 Coverages are divided by their respective rate and put into

    --a qry made field I.e.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply