Help needed with calculated query and count function

AmyB

New member
Local time
Today, 08:02
Joined
May 12, 2004
Messages
8
I've created a totals query to count the number of places that have been booked on each course. In the same query, I would also like to display how many spaces are left on each course.

However, the expression: Places Left: Sum([Capacity]-[Booked Places]) gives me the error message "Can't specify subquery in expression ([Capacity]-[Booked Places]).

The SQL is as follows:
SELECT DISTINCTROW [SS Booking 2004/5].CourseID, SSAllCourses.CourseName, SSAllCourses.StartDate, Count([SS Booking 2004/5].[Student No]) AS [Booked Places], Sum([Capacity]-[Booked Places]) AS [Places Left]
FROM [SS Booking 2004/5] INNER JOIN SSAllCourses ON [SS Booking 2004/5].CourseID = SSAllCourses.CourseID
GROUP BY [SS Booking 2004/5].CourseID, SSAllCourses.CourseName, SSAllCourses.StartDate;

How can I resolve this? Any help is greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom