title: SQL query that returns a subset of table plus column containing count for whole table
body: <p>I have one table named PEOPLE (Sex, Age, Weight) listed here:</p>
  
  <pre><code>Sex Age Weight
  M   10  81   
  F   21  146
  M   32  179
  F   40  129
  F   58  133
  </code></pre>
  
  <p>I would like to have the following data returned (Sex, Age, Weight, Count(*) as SexCount from PEOPLE where Age &lt; 35):</p>
  
  <pre><code>Sex Age Weight  SexCount
  M   10  81      2
  F   21  146     3
  M   32  179     2
  </code></pre>
  
  <p>I have found answers that work if I want to return all the people in the table (<a href="https://stackoverflow.com/questions/4259611/count-without-group">count without group</a>).</p>
  
  <p>But I have not found an answer if I want SexCount to include the total count from the whole table...and not just the total count from my returned subset. In other words, I want my returned data to just include people who are less than 35 years old, but I want the SexCount to include the count for all people in the table regardless of age.</p>
  
  <p>Anyone know a query that will return the data I want from the table example above? I am using Oracle if it makes a difference.</p>
  
  <p>I tried using this SQL phrase in my query: </p>
  
  <pre><code>COUNT(*) OVER(PARTITION BY Sex) as SexCount
  </code></pre>
  
  <p>But it only counted the number that were in my query results, and not in the whole table as I require (and explained above). Thanks.</p>