• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

SQL - CAST to two decimal places not working as expexted

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
ghettocounselor
Asked:
ghettocounselor
1 Solution
 
Alex MatzingerCommented:
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
 
ghettocounselorAuthor Commented:
Thanks for the quick response.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now