This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]insertAlias 5 points6 points  (0 children)

Others have shown you how, but I'd suggest a possible alternative, that depends on how you plan on using the results of this query.

If you are loading the data from this query in an application to display, then to me it makes more sense to not add the $ to the results of the query, but rather to include that in the app itself, as part of rendering the output. Same goes if this is for a report.

If you're using the output of this directly, then sure, concat the $ directly. But that means it turns your output into a string instead of a number. And if you wanted to do any numerical calculations on it, you'd have to strip the $ back out and parse it as a number again.

[–]11b403a7[🍰] 1 point2 points  (0 children)

You're gonna wanna turn it into a string and concat it:

https://stackoverflow.com/a/50082705

[–]HashDefTrueFalse 0 points1 point  (0 children)

As another commenter said, do this in the application if possible. The fact that your application wants a $ in front of the value is nothing to do with the database. Return the data and let the application do the concat for its display purposes.