Forum Moderators: open
I have two tables, Table1 and Table2 with fields like this:
Table1:
ID
Title
Level
Table 2:
ID
UserID
ListID (foreign key to table1.ID)
Status
The Status field can have one of two values, A or S. I am trying to select a count of A and a count of S, WHERE UserID is the logged in user (which is fine so far), but it needs to be grouped by Level from Table1
Level has possible values of Beginner, Middle and Advanced. So the results would look something like this:
Beginner(Level) 3(A) 0(S)
Middle (Level) 1(A) 1(S)
Advanced(Level) 0(A) 2(S)
SELECT count(Table2.ID) AS Active FROM Table2 WHERE Table2.UserID = '19' AND Table2.Status = 'A', count(Table2.ID) AS Studied FROM Table2 WHERE Table2.UserID = '19' AND Table2.Status = 'S'
but am not sure how to include the GOUP BY Level clause?