April 20, 2018 at 11:39 am
Hi
I have this
OP_Percentage * 100 as 'OP %'
OP_Percentage is a decimal(6,4) and if I try decimal(6,0 ) I just get 0
in a select statement. this gives a result like 125.00%
need this to look like this 125%
Any ideas?
Thank you
April 20, 2018 at 12:42 pm
itmasterw 60042 - Friday, April 20, 2018 11:39 AMHi
I have this
OP_Percentage * 100 as 'OP %'
OP_Percentage is a decimal(6,4) and if I try decimal(6,0 ) I just get 0
in a select statement. this gives a result like 125.00%
need this to look like this 125%
Any ideas?
Thank you
You can use format if you are an extremely patient person.
Normally for presentation issues, you want to handle that on the front end, in the application or report. In SQL Server, you can cast it to an int and then to a varchar so you can add the percent sign. SELECT CAST(CAST(OP_Percentage * 100 as int) as varchar(10)) + '%'
Sue
April 21, 2018 at 12:23 am
This can be simplified with the concat function.
😎
USE TEEST;
GO
SET NOCOUNT ON;
DECLARE @PERC DECIMAL(6,4) = 1.25;
SELECT CONCAT(CONVERT(INT,@PERC * 100,0),'%');
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply