我正在尝试使用一个子查询,该子查询稍后会出现在另一个计算中的列中。我怎样才能做到这一点?
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
所以基本上enrolled
我需要这个作为一个列来计算出来,也作为它自己的列。