Skip to content
Advertisement

MySql Group By Count item count Distinct

I have a table looks like

JavaScript

Here user id 1 exist in level 1 and level 2 Now when we count group by level then in counting we want ignore user_id 1 from level 1 cause it exist another group. we want to consider only one group existing and higher group.

I have done only group count but cant understand how ignore counting.

My current query is

JavaScript

My Query return counting

JavaScript

But I want looks like

JavaScript

Advertisement

Answer

I used this query and this gets the desired output check it out:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement