How can i convert this to a decimal in SQL? Below is the equation and i get the answer as 78 (integer) but the real answer is 78.6 (with a decimal) so i need to show this as otherwise the report won't tally up to 100%
(100 * [TotalVisit1]/[TotalVisits]) AS Visit1percent
At least in MySQL (if it helps), if you want to use float numbers you had to use a type float field, not the regular int fields.
Its probably overkill to do this, but you may wish to consider casting all values to floats to ensure accuracy at all phases.
Note, you really need to put code in here for the case that TotalVisits == 0 or you will get a division by 0 answer.
Ugly, but it works.
Just add a decimal to the 100
this forces all processing to happen in floats... if you want the final output as text, and truncated for display to only one decimal place, use Str function
This works perfectly for me:
Hope it helps someone out there in the world.
Try This: