sql - How can we merge the results of two queries have group by and two conditions -
i have these 2 tables: (games)
and (rounds) table:
i game id's, there round count, , count of how many rounds player1 wins. created 2 sql queries this:
but want results in 1 table. how can combine results this:
you can use conditional aggregation:
select game_id, count(*) roundscount, count(case when winner = player1_id 1 end) p1winscount games g inner join rounds r on g.id = r.game_id group game_id
Comments
Post a Comment