I have two columns in a table that are populated with integer values. For each record, I want to separate the values ββof these two columns and format the output so that the decimal point is moved to the places on the right.
For example, if I have the values ββof two columns for the same record as 4 and 1, and I want to divide 1 by 4 (so 1/4), then I want the result to be 25.00.
Here is the last thing I tried a little back:
CAST(Total AS Decimal(2))/CAST(TotalAnswers AS Decimal(2)) AS 'Percent'
I was unable to find a syntactical explanation of the CAST function to see that I passed the parameter for the decimal representation. When I change it, it sometimes changes the number of places to the right of the decimal, but the results are not always expected, so I would like to help with this a little.
casting sql sql-server-2005
Darren
source share