title: Unknown Inner Query Error
body: <p>I have the script below throwing an error on the inner query. I use Sequel Pro and am only getting this error:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT Savings
    FROM OfferSuggestionHeader osh
    LEFT JOIN Projects p
    ON osh.OfferI' at line 2</p>
  </blockquote>
  
  <p>So I'm uncertain as to what the actual issue is. I tried doing an explicit inner join within the inner query in case the <code>p</code> alias wasn't being referenced/interpreted properly or something similar, but that had no positive effect.</p>
  
  <pre><code>SELECT SUM(osh.Savings) as YTD, 
     SUM (SELECT Savings
  FROM OfferSuggestionHeader osh
  LEFT JOIN Projects p
  ON osh.OfferID = p.offer_id
  WHERE p.uid = 1 AND p.current_status &lt; 3) 
     AS "Open Savings"
  FROM OfferSuggestionHeader osh
  LEFT JOIN Projects p
      ON p.offer_id = osh.OfferID
  WHERE p.uid = '1'
  </code></pre>
  
  <p>Any help is appreciated. Best,</p>