title: Can I use an SQL statement to extract data from sheet A + sheet B and dump in in sheet C using only Excel
body: <p>I have data like this in Excel</p>
  
  <pre><code>table Cost_per_period
  ---------------------
  ProjectId
  FaseID
  Period
  Percentage
  
  table cost_per_partner_per_fase
  -------------------------------
  ProjectID
  FaseID
  PartnerID
  Amount
  
  table partners
  --------------
  PartnerID
  name
  </code></pre>
  
  <p>Here's the output I want.</p>
  
  <pre><code>                 2012             2013                2014     2015
  Project  fase    jan  feb ... dec  Q1    Q2   Q3   Q4  wholeY  wholeY
  ------------------------------------------------------------------------
  A310     1       100k 20k     10k  100k   -   10k  10k 1000k   2000k
  A310     2       110k   -     20k   99k   -   40k  50k 5000k   3000k
  ......
  </code></pre>
  
  <p>To combine this data, I'm thinking of doing a SQL statement like</p>
  
  <pre><code>SELECT cp.projectID, cp.faseID
    , case when cp.period between '2012/01/01' and '2012/01/31' 
           THEN sum(cpf.amount)*cp.percentage as jan2012 end
    , case when ..... as feb2012 end
    , case .......
  FROM cost_per_period as cp
  INNER JOIN cost_per_partner_per_fase as cpf 
    on (cp.postjectid = cpf.projectid) and (cp.faseid = cpf.faseid)
  GROUP BY cp.Projectid, cp.faseid
  ORDER BY cp.ProjectID, cp.FaseID
  </code></pre>
  
  <p><strong>Can I do this using only Excel?, I'm using excel 2007</strong></p>