根據(jù)相應(yīng)條件抽出相應(yīng)count數(shù)(myCount)
創(chuàng)新互聯(lián),專注為中小企業(yè)提供官網(wǎng)建設(shè)、營銷型網(wǎng)站制作、成都響應(yīng)式網(wǎng)站建設(shè)公司、展示型網(wǎng)站建設(shè)、成都網(wǎng)站制作等服務(wù),幫助中小企業(yè)通過網(wǎng)站體現(xiàn)價值、有效益。幫助企業(yè)快速建站、解決網(wǎng)站建設(shè)與網(wǎng)站營銷推廣問題。
抽出總count數(shù)(totalCount)
計算百分比:myCount / totalCount * 100
四舍五入:使用ROUND函數(shù)ROUND(number,要保留的小數(shù)位),ROUND(myCount / totalCount * 100,1)
下面給出示例供參考:
SELECT ROUND(T1.co/T2.totalCo*100,1)
FROM
(SELECT COUNT(*) AS co
FROM fup1
WHERE fup1.PERIOD6 = 1
AND fup1.P6CCTCHK = 2) T1,
(SELECT COUNT(*) AS totalCo
FROM fup1
WHERE fup1.PERIOD6 = 1)T2;