title: SQL - counting number of logins per day, per user
body: <p>I have a query that produces a table like the following: </p>
  
  <pre><code>Login_Date     Username
  ----------------------------------------------
  1/1/10         user-1
  1/1/10         user-1
  1/1/10         user-2
  1/2/10         user-1
  1/2/10         user-2
  1/3/10         user-1
  1/3/10         user-1 
  1/3/10         user-1
  1/3/10         user-3
  </code></pre>
  
  <p>The query looks like the following: </p>
  
  <pre><code>SELECT Date_Used, Name AS licenseNames FROM B, A WHERE A.License_Key = B.License_Key  ORDER BY Date_Used ;
  </code></pre>
  
  <p>which is fine, but what I need it to produce, is a list of dates, where for every date it gives me a list of users that logged in that day, along with how many times they logged in. I've looked all over to try and find a concise solution to this, but It's been nothing but dead ends. </p>
  
  <p>The result I want published would look like the following: </p>
  
  <pre><code>Login_Date    Username    # of Times logged in
  --------------------------------------------------
  1/1/10       user-1       2
  1/1/10       user-2       1
  1/2/10       user-1       1
  1/2/10       user-2       2
  1/3/10       user-1       3
  1/3/10       user-3       1
  </code></pre>
  
  <p>Any help would be much appreciated, this is driving me insane. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here are the respective tables, to avoid confusion: </p>
  
  <p>Table A Columns:</p>
  
  <pre><code>--------------------------
  ID   License_Key    Name
  </code></pre>
  
  <p>Table B Columns: </p>
  
  <pre><code>------------------------------
  ID    Date_Used     License_Key
  </code></pre>
  
  <p><strong>EDIT 2</strong> </p>
  
  <p>As per a comment request, all of the solutions thus far have provided the same result on the actual tables (although the SQL Fiddle works for all of them, so..?)</p>
  
  <p>The results I'm getting are as follows: </p>
  
  <pre><code>Login_Date     UserName     Cnt (or NumLogins for the other solution)
  ---------------------------------------------------------------------
  01-01-10       user-1        1
  01-01-10       user-1        1
  01-01-10       user-2        1
  01-02-10       user-1        1
  01-02-10       user-1        1
  01-02-10       user-1        1
  01-02-10       user-1        1
  </code></pre>
  
  <p>etc. etc. So it looks like the group by command in all of the answers thus far simply do.. nothing?? Very confusing...</p>