Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postive vs.Negative

Status
Not open for further replies.

zishan619

Programmer
May 28, 2003
284
MX
Hi I need to write a Case statement in saying
if the difference between two fields ends up being a positive number then place in the code and the number the field.
Then I will have another field to give me if the difference ends up being a negative number.
I have no idea how to start this case statement.
Please help. Thanks
 
Is this what you are looking for?

select
case when id1 > id2 then id1-id2 else null end as positive,
case when id2 > id1 then id2-id1 else null end as negative
from tbname

Why dont you give some sample and required result?
 
I figured it out thanks
I did:
'P/R Code'=(Case When TC.dblHoursW1_PR-TC.dblHoursW1 > 0 Then TC.PayrollID else null end),
'(+) Hours'=(Case When TC.dblHoursW1_PR-TC.dblHoursW1 > 0 Then TC.dblHoursW1_PR-TC.dblHoursW1 else null end),
'P/R Code'=(Case When TC.dblHoursW1_PR-TC.dblHoursW1 < 0 Then TC.PayrollID else null end),
'(-) Hours'=(Case When TC.dblHoursW1_PR-TC.dblHoursW1 < 0 Then TC.dblHoursW1_PR-TC.dblHoursW1 else null end)
Cool same theory
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top