Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH totals AS
- (
- SELECT score_description,COUNT(*) AS student_count, score,
- ( SELECT COUNT(*) FROM subtest_registration ) AS total_students -- WHERE subtest_id = 'e696b230-10e0-11df-80f4-1a7fbecf21f7'
- FROM subtest_registration_result
- INNER JOIN subtest_registration ON subtest_registration_id=id
- WHERE score_type_id = 2
- GROUP BY score_description, score
- )
- SELECT score_description, student_count,
- total_students,
- ( student_count * 100.00 ) / total_students as percentage
- FROM totals;
- score_description | student_count | total_students | percentage
- -------------------+---------------+----------------+---------------------
- M | 7803 | 40321 | 19.3521986061853625
- B | 7996 | 40321 | 19.8308573696088887
- E | 14596 | 40321 | 36.1994990203615982
- W | 9926 | 40321 | 24.6174450038441507
- (4 rows)
- real 0m0.078s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement