簡體   English   中英

在SQL查詢中格式化帶小數位的整數

[英]Formatting integers with a decimal place in sql query

我有這張表,是通過查詢得出的,如下所示:

Lasiorhinus 100
Macrotis    100
Myrmecobius 100
Panthera    50
Sarcophilus 100

查詢是這樣的:

select round (count(A) / count(B), 1)

但我希望數字的格式如下:

Lasiorhinus 100.0
Macrotis    100.0
Myrmecobius 100.0
Panthera    50.0
Sarcophilus 100.0

誰能幫我用ROUND(number,1)函數格式化整數50 => 50.0? 謝謝。

一種解決方案(SQL Server)是:

select format(round(count(A) / count(B), 1), 'N1')

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM