May 7, 2014 at 3:21 am
Hi,
I have these two columns
select
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)as MONEY),1), '.00', '') as Total_Amount,
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Monthly_Amount,2)as MONEY),1), '.00', '') as Monthly_Amount
from Finance
Now Monthly_Amount column should have calculated values like Total_Amount/12
May 7, 2014 at 3:31 am
vigneshkumart50 (5/7/2014)
Hi,I have these two columns
select
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)as MONEY),1), '.00', '') as Total_Amount,
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Monthly_Amount,2)as MONEY),1), '.00', '') as Monthly_Amount
from Finance
Now Monthly_Amount column should have calculated values like Total_Amount/12
Is this what you are after?
😎
select
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)as MONEY),1), '.00', '') as Total_Amount,
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)as MONEY) / 12,1), '.00', '') as Monthly_Amount
from Finance
May 7, 2014 at 4:00 am
yes also for monthly_amount I need to have two decimal values
Like
$ 134,98.55
$ 41.34
May 7, 2014 at 4:04 am
Just move the division inside the round function.
😎
May 7, 2014 at 4:09 am
like this
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)/12 as MONEY),1), '.00', '') as Monthly_Amount,
May 7, 2014 at 4:13 am
More like this
'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round((Total_Amount/12),2) as MONEY),1), '.00', '') as Monthly_Amount,
😎
May 7, 2014 at 4:26 am
vigneshkumart50 (5/7/2014)
like this'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)/12 as MONEY),1), '.00', '') as Monthly_Amount,
why CAST as MONEY and then REPLACE....couldn't you just cast as INT?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
May 7, 2014 at 4:35 am
J Livingston SQL (5/7/2014)
vigneshkumart50 (5/7/2014)
like this'$ '+REPLACE(CONVERT(VARCHAR(32),cast(round(Total_Amount,2)/12 as MONEY),1), '.00', '') as Monthly_Amount,
why CAST as MONEY and then REPLACE....couldn't you just cast as INT?
That would be implicit rounding:cool:
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply