October 6, 2014 at 5:34 am
Hi,
I am using this query to get the nearest value and rounding it.
floor(Price*DollarPrice) as Dollars
This returns result like below
31
34
567
Now I just need to add dollar symbol before the result. Please suggest me.
October 6, 2014 at 5:48 am
Formatting of display values is best done inside the application. Application programming languages are far better in manipulating strings.
If you realy want to do it in SQL you need to convert the value to a string and then add the $symbol to it, like:
SELECT '$' + CAST(floor(Price*DollarPrice) AS VARCHAR(10)) as Dollars
October 6, 2014 at 5:49 am
'$' + cast(floor(Price*DollarPrice) as varchar)
This will give you $xx. You won't be able to do any calculations on that though. If you need to do anything to the numbers it will probably be best formatting the final output as a money\currency datatype in the front end.
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply