我使用以下查询在新列中生成百分比,但我只想要两位小数。
SELECT
count( *) TestCount
,count(case when result_status = 'Not A Finding' then 1 end) TestPassedCount
,count(case when result_status = 'Not A Finding' then 1 end) / count(*) ThePercentage
,asset
FROM Table_Name
group by asset
当前输出:
TestCount TestPassedCount Percentage Asset
18 7 0.388888889 DB2MOTIV:DBMOTIVA@mxemch010405ads.mx.hsbc
必需输出:
TestCount TestPassedCount Percentage Asset
18 7 38.89 DB2MOTIV:DBMOTIVA@mxemch010405ads.mx.hsbc
此致
Bharath Vikas
答案 0 :(得分:0)
假设这是您想要实现的目标,只需将结果乘以100并添加round
函数:
SELECT
count( *) TestCount
,count(case when result_status = 'Not A Finding' then 1 end) TestPassedCount
,round((count(case when result_status = 'Not A Finding' then 1 end) / count(*)) * 100,2) ThePercentage
,asset
FROM
Table_Name
group by
asset
答案 1 :(得分:0)
使用ROUND方法
android:supportsRtl
答案 2 :(得分:0)
试试这个:
Round( count(case when result_status = 'Not A Finding' then 1 end) / count(*) * 100 , 2) ThePercentage