回答編集履歴
1
余談を追加
answer
CHANGED
@@ -23,4 +23,22 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
これをクエリビルダで表現できれば行けそうな気はします。
|
26
|
-
ソートもできるでしょうね。
|
26
|
+
ソートもできるでしょうね。
|
27
|
+
|
28
|
+
余談:
|
29
|
+
回答数が10件以上ある、という条件があるなら、
|
30
|
+
```SQL
|
31
|
+
SELECT
|
32
|
+
questions.id,
|
33
|
+
count(results.id) as total_answers_count,
|
34
|
+
sum(results.result) as correct_answers_count,
|
35
|
+
sum(results.result) * 100 / count(results.id) as correct_percent
|
36
|
+
FROM
|
37
|
+
questions
|
38
|
+
INNER JOIN results ON (results.question_id = questions.id)
|
39
|
+
GROUP BY
|
40
|
+
questions.id
|
41
|
+
HAVING
|
42
|
+
count(result.id) >= 10
|
43
|
+
```
|
44
|
+
で、「10件以上回答のある質問全ての、回答数と正答数と正答率」が一回で得られるかと。
|