sql - Is it possible to count all rows with the same id with COUNT? -
postgresql 9.4.
i have following table:
id player_id serial pk integer --------------------------- 1 1 2 3 ... ... 123123 1 i need count rows player_id = 1. possible count aggregate?
now follows:
sum(case when player_id = 1 1 else 0 end)
if need count of number of rows player_id 1, can this:
select count(*) your_table_name player_id = 1; if want count number of rows each player_id, need use group by:
select player_id, count(*) your_table_name group player_id;
Comments
Post a Comment