I am new to Postgres and databases so I am sorry. I ran a query to get a count of students per school from one table. Now I have the table below:
school_probs:
school_code(PK bigint) schoolName(text) probs(numeric)
1 CAA {0.05,0.08,0.18,0.3,0.11,0.28}
2 CAS {0.06,0.1,0.295,0.36,0.12,0.065}
3 CBA {0.05,0.11,0.35,0.32,0.12,0.05}
4 CL {0.07,0.09,0.24,0.4,0.06,0.09}
How would I go about multiplying the count from each school with each number in the probs column. Ex: We have total number of students at school "CAA" If it is 198, then the probability distribution will be
(0.05*198, 0.08*198, 0.18*198, 0.3*198, 0.11*198, 0.28*198)
. With the results I can then assign grades to students.
My query to get the count is as follows:
SELECT simulated_records.school, COUNT(simulated_records.school) as studentCount INTO CountSchool
FROM simulated_records, school_probs
WHERE simulated_records.school = school_probs.school
GROUP BY simulated_records.school;