Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Literal Percent Sign (%) to my calculation

I want to add a % sign to the derived values from the example below, is it possible? Do I have to somehow use CAST(n)?

ROUND(qy.TotalUnits/qy.TotalCalls *100) AS "Total Conv" +'%'
like image 461
user3749800 Avatar asked Jan 10 '23 09:01

user3749800


1 Answers

You should use CONCAT in MySQL to concatenate % with the values received from ROUND(<...>):

CONCAT(ROUND(qy.TotalUnits/qy.TotalCalls *100),'%')

At first, in MySQL + is used for arithmetic operations, secondly, you are trying to concatenate % with the alias, not values.

like image 80
potashin Avatar answered Jan 20 '23 17:01

potashin