How to query counting specific wins of team and find the winner of the series

后端 未结 1 862
说谎
说谎 2020-12-18 08:30

Table name: series_type

id| type| description 
1 |    0| No series (Any team win 1 will be the winner)
2 |    1| Best of 3 (Any tea         


        
相关标签:
1条回答
  • 2020-12-18 09:06

    I will using case, count and group by

    select winner, count(winner) from 
       (select case radiant_win 
                 when 1 then radiant_name 
                 else dire_name 
               end as winner
         FROM test.`match` ) as temp
    group by winner;
    
    • test.'match' is a testing table i created in MySQL

    Update

    I can't find start_time, radiant_team_id and dire_team_id as what you posted in the comment after you updated your question.

    Below answer might not be the one you want since I'm not so clear on your question after you updated it.

    select *, count(winner) as count 
    from (select case radiant_win 
                when 1 then radiant_name 
                else dire_name 
            end as winner, 
            radiant_team_id, 
            dire_team_id,
            series_id,
            series_type
        from test.`matches` 
        where league_id = 2096 and 
              start_time >= 1415938900 and 
             ((radiant_team_id= 1848158 and dire_team_id= 15) 
               or (radiant_team_id= 15 and dire_team_id= 1848158)) 
        ) as temp
    group by winner;
    
    0 讨论(0)
提交回复
热议问题