Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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 
    then
        wq.quantity_on_hand * ( im.last_repack_item + im.freight_item ) 
    else
        0
  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
672242738
accept rate: 8%

edited 03 May '13, 11:44

Volker%20Barth's gravatar image

Volker Barth
40.2k361550822


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
24.9k10141297
accept rate: 41%

edited 03 May '13, 11:25

1

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×69
×13
×5

question asked: 03 May '13, 11:19

question was seen: 2,332 times

last updated: 03 May '13, 11:44