开发者

SQL - How do i output string with numbers in sql?

开发者 https://www.devze.com 2023-02-07 17:36 出处:网络
I want to get a number 5000.1 and divide it by 1000 before adding an \"F\" infront of it. How do开发者_运维问答 i do this? I tried and failed this:

I want to get a number 5000.1 and divide it by 1000 before adding an "F" infront of it.

How do开发者_运维问答 i do this? I tried and failed this:

select "F" + round ( acq.store_size_net / 1000, 0) from acq


I suspect your missing the cast of the number to a text data type

Without knowing the exact dialect of sql you're using im gonna hazard a guess at ms-sql

select 'F' + cast(cast(round ( 5000.1 / 1000, 0)as int) as nvarchar(50))

produces output F5


This will work in Oracle :

 select 'F' || round (acq.store_size_net / 1000, 0) from acq 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号