mysql 预算准确率抒写
时间: 2023-12-02 13:43:00 浏览: 386
以下是MySQL计算准确率的SQL写法:
```sql
SELECT ROUND(T1.co / T2.totalCo * 100, 1) as accuracy
FROM
(SELECT COUNT(*) AS co
FROM topic_exercise
WHERE user_id = 844228520938668032 AND user_answ=topic_answ) T1,
(SELECT COUNT(*) AS totalCo
FROM topic_exercise
WHERE user_id = 844228520938668032) T2;
```
该SQL语句通过查询`topic_exercise`表中用户ID为`844228520938668032`的记录,统计用户答题正确的数量`T1.co`和用户答题总数`T2.totalCo`,并计算准确率。最终结果保留一位小数,以百分比形式展示。
阅读全文