## How to convert to two decimal places

 Author Message hoseam SSC Veteran Group: General Forum Members Points: 233 Visits: 427 HiI have this code herecase when chargeType <> 'ADV_SWITCH_FEE' then CAST(isNull(sum(chargeAmount)/100.0, 0.0) AS VARCHAR) else '' end as chargeAmountHow do I convert my "sum" into decimal places? anthony.green SSCertifiable Group: General Forum Members Points: 6108 Visits: 6080 You will need to convert it to a data type which allows you to specify the amount of decimal places you want, you would want decimal with the correct precision to cope with how ever many decimal places you need. Want an answer fast? Try hereHow to post data/code for the best help - Jeff ModenWhen a question, really isn't a question - Jeff SmithNeed a string splitter, try this - Jeff ModenHow to post performance problems - Gail ShawCrossTabs-Part1 & Part2 - Jeff ModenSQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola HallengrenManaging Transaction Logs - Gail ShawTroubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger BriPan SSC Journeyman Group: General Forum Members Points: 85 Visits: 296 is your chargeAmount is INT then you need to convert it to decimal to get decimal in SUM hoseam SSC Veteran Group: General Forum Members Points: 233 Visits: 427 My charge amount need to cater for both "Then" and "Else", my "else" returns string hence I cast it as varchar. that code so far is working but I need to return two decimal value amount. anthony.green SSCertifiable Group: General Forum Members Points: 6108 Visits: 6080 Vedran Kesegic Old Hand Group: General Forum Members Points: 382 Visits: 1255 Use STR function. E.g:`declare @x money=12345.69851SELECT [STR]=STR(@x, 20, 2), [CONVERT_default]=CONVERT(varchar(20), @x), [CONVERT_format_1]=CONVERT(varchar(20), @x, 1), [CONVERT_format_2]=CONVERT(varchar(20), @x, 2)` _____________________________________________________Microsoft Certified Master: SQL Server 2008XDetails Addin - for SQL Developersblog.sqlxdetails.com - Transaction log myths