title: Query Active & Inactive Connections based off Machine and Username
body: <p>I'm attempting to make a query that lists a count of Active, Inactive &amp; Total number of connections per machine, per username in an Oracle 10g database.</p>
  
  <p>I have the following Query:</p>
  
  <pre><code>SELECT count(1) AS con_count, machine, username 
  FROM v$session 
  WHERE type &lt;&gt; 'BACKGROUND'
  GROUP BY username, machine 
  ORDER BY con_count DESC;
  </code></pre>
  
  <p>That will list a count of the # of total connections per machine per username but am having trouble adapting it to do a count of Active, Inactive &amp; Total connections as an all in one query.</p>
  
  <p>So results should be something like:</p>
  
  <pre><code>ACTIVE   INACTIVE   TOTAL   MACHINE   USERNAME
  </code></pre>
  
  <p>And I can make the query do one of the first three columns but not all three at once.</p>
  
  <p>Any help would be appreciated, as my SQL is very, very rusty.</p>