Solved

SQL - CAST to two decimal places not working as expexted

Posted on 2014-04-18
2
303 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

19 Experts available now in Live!

Get 1:1 Help Now