Using date and CASE

  • I have a table with 8 rows in it and 5(p1......p5) of them having float values. They indicate no of hours a person works.

    if year is 2011 and month is jan and date is 01 then p1 value must me zero else remaining days multiplied with number of hours worked per day.

    if month is feb then p1+ either 0 or p1+remaining days*hours in feb and if date is 28th then p1+p2 comp.

    It follows upto may.

    I worked with CASE and IIF functions but I couldnt get the result correctly

    Could anyone help me on this.

  • Ok, Share the scripts to create the table and test data. so that i can simulate the same on my machine, This would help me to help you.

    Thanks

    Ashok

  • Apart from individual DDL and test data, your logic seems incomplete. I would revisit this and better explain what the process is for computation.

    You can use CASE for some of this.

    CASE when day = 1 and month = 'Jan' then 0

    when day > 1 and month = 'Jan' then hours * rate

    end

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

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