SQl Statement Sum
Question by helloman
Hey guys I am trying to sum these tables and I can’t figure out what I’m doing wrong
My first table is:
Reserve
ReserveID MembershipID PlayerCount Time CourseID
My second table is
Courses
CourseID Name
My sql statement that I am trying is here:
Select Sum(Reserve.Player_Count)Total
From Reserve
Left Join Courses
On Courses.CourseID = Reserve.ReserveID
Where Time = "2012-04-09 07:10:00"
And Courses.Name = "Lake" (or I had Courses.CourseId = "1")
Answer by Starx
You seem to mixing alias. Avoid them
Select Sum(Reserve.Player_Count)Total
From Reserve
Left Join Courses
On Courses.CourseID = Reserve.ReserveID
Where Reserve.Time = "2012-04-09 07:10:00"
-- ^ Right here
And Courses.Name = "Lake" (or I had Courses.CourseId = "1")