Solved

SQL - CAST to two decimal places not working as expexted

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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