• Suppose I wish to get the name of persons who are in group_name=2 and I got :

    aaa,eee,abc,ccc and ddd.

    Now, aaa person also belongs to grp3 and grp4, so in the query output grp3 column should have 2 (because 2 times) and in the grp4 column should have 1 (1 times in the table).

    For eee person, who belongs to only grp2 for which current query is running, but he do not belongs to any other group, so null or zero in grp1, grp3 and grp4 columns.

    Person abc also belongs to grp1, so in the query output column grp1 should have 1 (1 time of grp1).

    Person ccc also belongs to grp4, so in the query output column grp4 should have 1 ( 1 time of grp4).

    Person ddd also belongs to grp1, so in the query output column grp1 should have 2 (2 time of grp1).

    I hope now I am clear and please help me.