Solved

SQL - CAST to two decimal places not working as expexted

Posted on 2014-04-18
2
306 Views
Last Modified: 2014-04-18
I would expect that this:
CASE WHEN [ROUTE] IN ('PO','TOP','INH','TP','VAG') THEN CAST(MED_PRICE AS DECIMAL(18,2)) ELSE IV_PRICE END PT_CHARGE_BY_DU

would not give me 96.8800
but alas it does
0
Comment
Question by:ghettocounselor
2 Comments
 
LVL 4

Accepted Solution

by:
Alex Matzinger earned 500 total points
ID: 40009751
What database are you using?  

is it possible that the 96.880 is not in  ('PO','TOP','INH','TP','VAG') so it is not being cast to a decimal?

Try this:

CASE WHEN [ROUTE] IN ('PO','TOP','INH','TP','VAG')
   THEN CAST(MED_PRICE AS DECIMAL(18,2))
   ELSE CAST(IV_PRICE AS DECIMAL(18,2)) END PT_CHARGE_BY_DU

And see what happens
0
 

Author Closing Comment

by:ghettocounselor
ID: 40009761
Thanks for the quick response.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now