• Post Reply Bookmark Topic Watch Topic
  • New Topic

decode in db2

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a requirement like
if payment_type = 's' then compensation is weekly_rate * 4
but if weekly_rate is 0 or null then compensation is 0
if payment_type = 'p' return the value in gross_amount column.

Below is the decode function I have used. Would like to know how to do the same using db2 functions.

Decode(payment_type, �s�, (decode(nvl(weekly_rate,0.00),0.00,0.00, weekly_rate*4)) ,�p�,gross_amount)
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!