title: how to calculate percent of total within group by statement?
body: <p>I have a table with 1 record per sale per salesperson per day</p>
  
  <pre><code>NAME  DATE
  joe   1-1-13
  joe   1-1-13
  joe   1-1-13
  dave  1-1-13
  joe   1-2-13
  </code></pre>
  
  <p>I used this to create &amp; populate the table</p>
  
  <pre><code>create table #sales (name varchar(10), salesdate date )
  insert into #sales (name, salesdate) 
  values ('joe', '01-01-2013'), ('joe','01-01-2013'), 
         ('joe', '01-01-2013'), ('dave','01-01-2013'),  
           ('joe','01-02-2013')
  </code></pre>
  
  <p>I want a query to pull up the percent of each salesperson's sales by day</p>
  
  <p>(for example  on 1-1-13 Joe sold 3 units out of 4 total for the day (75%) 
  but I dont know how the SQL can pull up the daily total of all sales for the day regardless of salesperson</p>
  
  <p>This is as close as I got. </p>
  
  <pre><code>select name, salesdate, count(*) as "dailyTotal"
  from #sales
  group by name, salesdate
  </code></pre>
  
  <p>How can I include the daily total that is so that it can be used in calculating percent total for the day?</p>