The forum will be down for maintenance at some point from Friday, November 16 at 19:00 EDT until Sunday, November 18 at 23:59 EDT. Downtime will be minimized but the exact timing is unknown.

this case statement does not return the result i'm expecting

the value of wq.quantity_on_hand = 156, im.last_repack_item = 0, im.freight_item = .38010

( Case when im.last_repack_item = 0 
        wq.quantity_on_hand * ( im.last_repack_item + im.freight_item ) 
  END ) repack_cost,

the select returns 59.2956 (156 * .38010) i thought it should return 0

i've worked around it by creating multiple columns, but i'd like to know if it's a bug, or if it's the way it's supposed to work.

thanks Tom M.

asked 03 May '13, 11:19

Tom%20Mangano's gravatar image

Tom Mangano
accept rate: 6%

edited 03 May '13, 11:44

Volker%20Barth's gravatar image

Volker Barth

Why would you expect the expression to return 0?

The expression 'im.last_repack_item = 0' evaluates to TRUE since you tell us that last_repack_item is zero, so the value of the 'then' clause is returned.

permanent link

answered 03 May '13, 11:23

Mark%20Culp's gravatar image

Mark Culp
accept rate: 40%

edited 03 May '13, 11:25


i've looked at it for 15 mins, checked values, etc. i'm in the office by myself today, so thanks for looking over my shoulder.

(03 May '13, 11:33) Tom Mangano
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 03 May '13, 11:19

question was seen: 1,163 times

last updated: 03 May '13, 11:44