var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: formatting decimal places in a query in MS SQL
Hey - I have a quick question and know that it is probably pretty simple, but I am stumped. I have a query where I need to make a colum a number that looks like a percent with 2 significant digits:
SELECT tblNumericCovert.number1, tblNumericCovert.number2, [number1]/[number2] AS testDiv
where testDiv needs to spit out results like this ###.##
I am totally lost, if anyone can help, I would appreciate it.
cast(cast(YourValue as decimal(10,2)) as varchar(6)) + '%'
But really, data formatting issues should be handled by the interface, not sql server. Do your formatting in Crystal, VB, ASP, Excel, or whatever else you are using to display results.
It will do the rounding though:
select right('000000'+ltrim(str(123.87745, 6, 2)), 6) + '%'
Probably better to use ROUND for rounding, so you know what you are trying to accomplish when you look at your code...
SELECT ROUND(127.4355,2) = 127.4400
That works perfectly! Thanks. I've always used Access which is a breeze and I'm trying to use SQL more. I really appreciate all of y'alls help on this.
Originally posted by rdjabarov