title: SQL: query two time periods with relevant matching data only
body: <p>Please forgive the title of this question, but I can't think of concise way of asking the below.</p>
  
  <p>In a nutshell, I have about 400 stores whose transactions I want to compare now and the same time last year. The problem is that last year, some stores weren't around or had no data and vice-versa. I want to write a query that compares now and then only where I have store data in both time periods.</p>
  
  <p>Consider this data:</p>
  
  <pre><code>storeID   tranDate     qty  sale
  A         2013-12-01     1   $10
  B         2013-12-02     1   $10
  C         2013-12-03     1   $10
  D         2013-12-04     1   $10
  A         2012-12-05     1   $10
  A         2012-12-09     1   $10
  D         2012-12-06     1   $10
  E         2012-12-07     1   $10
  F         2012-12-08     1   $10
  </code></pre>
  
  <p>To query December data, I would do something like:</p>
  
  <pre><code>select * 
  from myTable
  where (tranDate between @DateStart and @DateEnd) or (tranDate between @DateStartPreviousYear and @DateEndPreviousYear)
  </code></pre>
  
  <p>But if I wanted to query December like-for-like (i.e. Stores A and D are the only common to stores to both now and last year), how would I do this?</p>
  
  <p>In my real world, I will have about 2 million transactions per month over about 400 stores.</p>
  
  <p>Please help! Thanks in advance!</p>
  
  <p>EDIT: Thanks for your answers so far. I have edited my sample data to include two records for store A in December 2012 - am I right in saying that this causes a problem for joining on StoreID</p>