Quantcast
Channel: User Graygood - Stack Overflow
Viewing all articles
Browse latest Browse all 32

Get finished level distribution across the database

$
0
0

I have a table that stores data of players game sessions. I need to count how many players finished each level of a game.

Table have this structure`

player_id, player_level, online_time, offline_time, register_time7461919470860005376, 9, 21/06/19 20:22, 21/06/19 23:55, 20/06/19 18:22

What I was trying to do is getting max level for each player_id

Like this

SELECT x1.level, count(*)FROM(SELECT player_id, max(player_level) as levelFROM session_endGROUP BY player_id) x1GROUP BY level

Now, knowing that, I need to somehow add up players that have max level == 2 to the row of max level == 1, because of the fact that if player finished level 2, it means that it finished level 1 and so on.

How could I do that using PSQL-syntax?


Viewing all articles
Browse latest Browse all 32

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>