October 17, 2007 at 7:07 am
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
October 17, 2007 at 7:17 am
:ermm: suspicious question
SELECT employeeid, sickleavehours + (vacationhours * salariedflag) AS [paidtimeoff]
Far away is close at hand in the images of elsewhere.
Anon.
October 17, 2007 at 7:18 am
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
November 21, 2011 at 11:22 pm
Check this..........
SELECT Employeeid ,
CASE WHEN salariedflag = 1 THEN vacationhours + sickleavehours
ELSE sickleavehours
END paidtimeoff
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy