How can I get a number with a thounds separator on top?

前端 未结 1 861
北荒
北荒 2021-01-29 07:34
SELECT count(*) FROM table A

let\'s say the result is 8689. How can I convert it to 8\'689

1条回答
  •  抹茶落季
    2021-01-29 08:09

    Try This way:-

    select replace(convert(varchar,convert(Money,  count(*)),1),'.00','') 
    from table_name
    

    and be sure you really need this approach, formatting the application is the usual and best as SqlZim said.

    UPDATE:-

    for setting the separator on top, Try the next:-

    select replace( replace(convert(varchar,convert(Money,  count(*)),1),'.00',''),',','''')
    from table_name
    

    0 讨论(0)
提交回复
热议问题