title: Sqlite - Count Unique Values based on Column
body: <p>I've got a table like this (C, Sqlite). And I want to count the number of <strong>unique</strong> ports each IP address contacts.</p>
  
  <pre><code>id | ip_src       | ip_dst | port 
  -----------------------------------
  1  | 192.168.45.3 | ...    | 442
  2  | 132.43.13.4  | ...    | 42
  3  | 111.5.34.3   | ...    | 80
  4  | 54.2.2.1     | ...    | 8322
  5  | 54.2.2.1     | ...    | 8322
  6  | 192.168.45.3 | ...    | 80
  7  | 192.168.45.3 | ...    | 23
  </code></pre>
  
  <p>The result of the query should ideally look something like this:</p>
  
  <pre><code>192.168.45.3 = 3
  132.43.13.4 = 1
  111.5.34.3 = 1
  54.2.2.1 = 1
  </code></pre>
  
  <p>What would the query look like for this?</p>
  
  <p>I've tried:</p>
  
  <pre><code>SELECT src_ip, COUNT(DISTINCT port) FROM synpackets;
  </code></pre>
  
  <p>But it's not giving out the correct result, it seems to be only counting the first IP address. </p>