I'm constructing a database that will track municipal government board and committee members. There are about 20 different committees in town, each having a different number of required members for different roles. A typical committee could require 5 "regular" and 3 "associate" members. I'd like to create a query that counts the actual number of members in each role for each committee, and returns those which are less than the required number.
Table definitions -
I'm new to SQL so I'm having a hard coming up with this query. I really appreciate your help.
Thank you,
John
Table definitions -
The requirements of each committee is stores in a ComMemReqs junction table that is fed by a committees and memberRoles table.
MemberRoles has the heading of MemberRoleID and MemberRole. Typical entries are of the form {1,Member} and {2,Associate}.
Committees have an committeeID, committeeName, and some other attributes that are irrelevant to this particular query.
ComMemReqs is the junction table. Its heading is CommitteeName (FK), MemberRole(FK), and RequiredNumber
There is a servesOn table that specifies the actual membership of each committee. It has a memberName attribute (FK from the members table), CommitteeName (FK from the committees table) and memberRole (FK) from the memberRoles table.
MemberRoles has the heading of MemberRoleID and MemberRole. Typical entries are of the form {1,Member} and {2,Associate}.
Committees have an committeeID, committeeName, and some other attributes that are irrelevant to this particular query.
ComMemReqs is the junction table. Its heading is CommitteeName (FK), MemberRole(FK), and RequiredNumber
There is a servesOn table that specifies the actual membership of each committee. It has a memberName attribute (FK from the members table), CommitteeName (FK from the committees table) and memberRole (FK) from the memberRoles table.
I'm new to SQL so I'm having a hard coming up with this query. I really appreciate your help.
Thank you,
John