0
你好這裏是我的SQL代碼:SQL似乎在select語句中自動舍入數字?
SELECT a."Date", a."Missed", b."Total Client Schedules", cast(100-((a."Missed"*100)/b."Total Client Schedules")AS decimal) as "Pct Completed" -
FROM -
(-
SELECT DATE(scheduled_start) as "Date",count(*) as "Missed" FROM -
events WHERE node_name IS NOT NULL AND status IN ('Missed') GROUP BY DATE(scheduled_start) -
) as a, -
(-
SELECT DATE(scheduled_start) as "Date", count(*) as -
"Total Client Schedules" FROM events WHERE node_name IS NOT NULL GROUP BY DATE(scheduled_start) -
) as b -
WHERE a."Date" = b."Date" ORDER BY "Date" desc
,這裏是輸出
Date Missed Total Client Schedules Pct Completed
----------- ------------ ----------------------- --------------
2013-02-20 2 805 100
2013-02-19 14 805 99
2013-02-18 29 805 97
2013-02-17 59 805 93
2013-02-16 29 806 97
2013-02-15 49 805 94
2013-02-14 33 805 96
2013-02-13 57 805 93
2013-02-12 21 805 98
2013-02-11 35 805 96
2013-02-10 34 805 96
它似乎總是舍入到最高數字時,我希望它像99.99%或97.2%等..
似乎沒有工作。我正在使用IBM TSM數據庫,所以這可能不是那麼可行:( – user2026188 2013-02-20 01:59:13
確定它已經工作了,現在我把它改爲round(100.0 - ((a。「Missed」* 100.0)/ b。「Total Client Schedules」), 2) – user2026188 2013-02-20 02:02:40
但現在數字顯示爲99.75000000000000000,所以我只需要擺脫所有的0:D – user2026188 2013-02-20 02:03:32