title: Loop all rows in a table PL/SQL then count
body: <p>I'm trying to loop all row in a table and count the appearances of each elements in the table.</p>
  
  <p>I need to find the active player (Active = Y) in the table PLAYER that have much friends. 
  I have tried some methods for loop in a table but i did not success.</p>
  
  <pre><code>CREATE TABLE PLAYER(   
      NO_PLAYER INTEGER           
      Active  CHAR(1) -- Y is yes and N is no
  );
  
  
  CREATE TABLE FRIEND(
      NO_PLAYER_Inviter INTEGER  -- player who invite the others              
      NO_PLAYER_Invited INTEGER  -- player who is invited         
  );
  </code></pre>
  
  <p>Suppose in table PLAYER we have players 1 2 3 are actives, player 4 is inactive, then I have these records in table FRIEND</p>
  
  <p><strong>NOTE</strong>: we accept the duplicate</p>
  
  <pre><code>which means
  1 2
  2 1
  2 3
  then we say that 2 has 3 friends.
  </code></pre>
  
  <pre><code>table FRIEND:
  1    2
  1    3
  1    4  -- we will not consider 4 is a friend of 1 as 4 is inactive
  2    1
  2    4  -- we will not consider 4 is a friend of 2 as 4 is inactive
  3    1
  4    3  -- we will not consider 4 is a friend of 3 as 4 is inactive
  I expect the result is 
  player 1 has 4 friends
  player 2 has 2 friends
  player 3 has 2 friends
  player 4 has 0 friends 
  
  and the code return player 1
  </code></pre>