sql - Can someone tell me how to put a $ with numbers? -
i have query have use convert
function return unitprice decimal 2 digits right of decimal , $ left of number.
for example : 10 should $10.00
can tell me how insert $?
this code far
select convert(varchar, unitprice, 1) varchartotal dbo.[order details]
this type of thing should always done in ui. surely wherever you're displaying data has way format value currency, , culture (what happens when need display euros or yen or different symbol?).
that said, problem simple string concatenation can solve:
select '$' + convert(varchar, unitprice, 1) varchartotal dbo.[order details]
note: don't approve of ever being used in production environment.
edit: there's confusion whether mean mysql or sql server. if you're using mysql, can't use convert
here, can cast char instead:
select concat('$', cast(unitprice char(20))) varchartotal dbo.[order details]
Comments
Post a Comment