sql - calculating the number of references of a key in different table -


i have below sql query:

select      g.name gname,       count(u.id) nomembers,     f.name client,     p.name projectname,     g.formed_date formeddate  `groups` g join users u on u.group_id = g.id join users f on g.client_id = f.id join projects p on p.group_id = g.id 

what i'm trying accomplish this: single sql query name of current group, number of members within (all users in same different table, called users), name of project group working on , client group working. has done every group in groups table.

when execute above query not return number of users within group, more (not of users in table though) , 1 row of results, although there supposed more.

count going return 1 row whole selection. want use group after join statements.

group g.name 

this give 1 row each different group name. return 1 result per group name client, projectname, , formeddate, if there multiple different possibilities within each group, may want group multiple columns more details, example:

group g.name,f.name 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -