- Home
- Anonymous
- Sign in
- Create
- Ask a question
- Spaces
- Site Issues (NOT FOR DATABASE QUESTIONS)
- Explore
- Topics
- Questions
- Users
- Badges

Any help is appreciated. I would like the values to show 0.0%. I tried all the following methods but getting error messages: •STR(ROUND(([Future]*100.0/Total), 2) as decimal(5,1)) + '%' as 'Percentage' •Incorrect syntax near the keyword 'AS' •cast(ROUND(([Future]*100.0/Total), 2) as decimal(5,1)) + '%' AS 'Percentage' •Error converting data type varchar to numeric. •CAST(ROUND(([Future]*100.0/Total), 2) as decimal(5,1)) AS 'Percentage' •This gives me the desired result (0.0), but without the % symbol. •str(ROUND(([Future]*100.0/Total), 2)) + '%' AS ‘Percentage’ •This works but without the decimals (0%) STR(CAST(ROUND(([Future]*100.0/Total), 2) as decimal(5,2))) + '%' - This works but again without the decimals (0%) Not sure what am I doing wrong.

decimal
Comment

Try this please CAST((CAST(ROUND(([Future]*100.0/Total), 2) as decimal(5,1))) AS VARCHAR)+'%' AS [Percentage]

What version of SQL Server? If you're on 2012 or above, there's the [`FORMAT`][1] function. SELECT FORMAT(1.0/2.0,'p') result: 50.00 % [1]:
https://msdn.microsoft.com/en-GB/library/hh213505.aspx

**18** People are following this question.

Copyright 2022 Redgate Software.
Privacy Policy