存储无商店名称地区部门Q10(响应)Q21(响应)
2345 ABC North Test 1 5
2345 North Test 6 3
2345 ABC North Test 4 6
第一次计算
1)参与(%)=响应大于4.5
3(总响应大于4.5)/ 6(总计数)* 100 = 50%
存储无商店名称地区划分Q10 Q21
2345 ABC North Test 1 5
2345 ABC North Test 6 3
2345 ABC North Test 4 6
2)未参与(%)=响应少于2
1(总响应小于2)/ 6(总计数)* 100 = 16.66%
我应该可以像这样获得表格
存储没有商店名称区域划分参与(%)脱离(%)
2345 ABC North Test 50 16.66
答案 0 :(得分:2)
您的统计信息在点(T-SQL)之后舍入2位数,按商店分组:
SELECT
store_no,
store_name,
region,
division,
ROUND( CAST( (SUM(CASE WHEN q10 > 4.5 THEN 1 ELSE 0 END) + SUM(CASE WHEN q21 > 4.5 THEN 1 ELSE 0 END)) AS FLOAT) / (COUNT(q10)+COUNT(q21)) * 100, 2) AS engaged,
ROUND( CAST( (SUM(CASE WHEN q10 < 2 THEN 1 ELSE 0 END) + SUM(CASE WHEN q21 < 2 THEN 1 ELSE 0 END)) AS FLOAT) / (COUNT(q10)+COUNT(q21)) * 100, 2) AS not_engaged
FROM
yourtable
GROUP BY
store_no,
store_name,
region,
division