"fetch"

  • How to fetch the records when salary flag equal to 1 then sum up the corresponding vacation hours and sick Leave hours. If salary flag is Zero then display the sick Leave hours alone

    Condition: use single select statement with out where clauses.

    employeeid salariedflag vacationhours sickleavehours

    1 0 3 4

    2 1 4 6

    3 0 2 1

    4 1 1 8

    Expected Output

    Employeeid paidtimeoff

    1 4

    2 10

    3 1

    4 9

  • :ermm: suspicious question

    SELECT employeeid, sickleavehours + (vacationhours * salariedflag) AS [paidtimeoff]

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Is this a homework question? You'll find that people are more likely to help you if you show what you've tried so far.

    John

  • Check this..........

    SELECT Employeeid ,

    CASE WHEN salariedflag = 1 THEN vacationhours + sickleavehours

    ELSE sickleavehours

    END paidtimeoff

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

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