sql - query to segregate users based on role per project in mysql -


I have a table that includes Project IDs, User IDs and RollIds with other columns.

I am trying to get a query that will give users to each project based on the role.

I tried and if the case statement but it was able to know.

table:

  projectid | User ID Role | Flag 1000001 | 20001 | 1 | Y 1000001 | 20002 2 | Y 1000001 | 20003 | 2 | Y 1000001 | 20004 | 3 | Y 1000001 | 20005 1 | Y 1000002. 20006. 3 | Y   

role 1 = junior, 2 = tl, 3 = consider the hyde, I'm trying to find something like this

  projectid | Junior | TL | HOD 1000001 | 20001, 20005. 20002, 20003. 20004 1000002 | ------------- | ------------- | 20006    

You need to use

  Select projectid, group_concat (case when roleid = 1 userid end) junior, group_concat (case when roleid = 2 userid end) senior, group_concat (case when roleid = 3 userid end) by projectid by TL table1 group   



Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -