Issue creating query in mysql
I have two tables, in mySql database, like these :
GROUPS:
| IDGroup| IDRat| Type| Category|
| 708 | 354 | 1 | A |
| 709 | 354 | 1 | C |
Where IDGroup is the primary key.
USERS:
| IDUser| Name| Surname | IDGroup |
| 1 | John| Doe | 708 |
| 2 | Mick| Caine | 708 |
Where the primary key is IDUser
I want create a query that, receives as parameter the IDRat and returns
the results like this:
| IDGroup| Type| Category | Number_of_Users_in_this_group |
where, as the name suggest, the fourth column represents the number of
users associated with the group.
For example passing the IDRat = 354 I want obtain the following result:
| IDGroup| Type| Category | Number_of_Users_in_this_group |
| 708 | 1 | A | 2 |
| 709 | 1 | C | 0 |
No comments:
Post a Comment