I'm trying to use a subquery that comes out into a column in another calculation later on. How can I do this?
SELECT c_id, c_title, c_enrolcap,
(SELECT COUNT(e_id) AS enrol FROM enrollments WHERE e_c_id = c_id) AS enrolled,
c_enrolcap - enrolled AS avail,
FROM classes AS c
So basically what comes out of enrolled I need this as a column to calculate off of later and also as it's own column.