2019年1月22日 星期二

Sqlite整數型態轉成實數型態之方法

Sqlite的count函數係整數值,如計算2個count次數之比率時,整數相除會得0,要怎麼變成實數,方法如下:

with a as (select count(*) as ct from 輔具評估日誌 where 接案日 = '0.0')
    ,b as (select count(*) as ct from 輔具評估日誌)
select a.ct, b.ct, a.ct*1.0/b.ct from a, b

沒有留言:

張貼留言