title: Unable to use sub queries sql with single table
body: <p>I am trying to query one network packets table using mysql. But I am not able use sub query using sql. Here is my table structure </p>
  
  <pre><code>CREATE TABLE netpacket IF NOT EXISTS
  (src_port INT,
   status STRING);
  </code></pre>
  
  <p>This is how my first 5 records of table (There are 17k records):</p>
  
  <pre><code> --------------------------
  | src_port |  status       |
   --------------------------
  |   53     |  active       |
   --------------------------
  |   4321   |  active       |
   --------------------------
  |   53     |   active      |
   ---------------------------
  |   8000   |  running      |
   --------------------------
  |   8721   |  idle         |
   --------------------------
  |   8000   |  running      |
   --------------------------
  |    21    |  connected    |
   --------------------------
  |    53    | disconnected  |
   --------------------------  
  |    53    |  disconnected |
   --------------------------
  |    53    |  active       |
   --------------------------
  </code></pre>
  
  <p>There are five status in the given table(Namely <em>active</em>, <em>disconnected</em>, <em>connected</em>, <em>idle</em>, <em>running</em>). </p>
  
  <p>Now what I am trying to do is, I want the count and number of src_port along with it's status like this:  </p>
  
  <pre><code> -----------------------------------------------------  
  |    src_port    |  src_port_count    |  status       |
   -----------------------------------------------------
  |    8000        |       2            |  running      |
   -----------------------------------------------------
  |    53          |       2            |  disconnected |
   -----------------------------------------------------
  |    53          |       3            |  active       |
   -----------------------------------------------------
  </code></pre>
  
  <p>And this what I have tried so far now,</p>
  
  <pre><code>select count(src_port) as src_port_count from netpacket where status in (select status from netpacket  where status='running')
  
  </code></pre>
  
  <p>But only I'm getting error like this </p>
  
  <pre><code>SYNTAX_ERROR: line 1:60: value and result of subquery must be of the same type for IN expression: integer vs varchar
  </code></pre>
  
  <p>I am not sure about sub query, but is there any other way to achieve this?</p>