title: Cannot join two table after using AS in SQL Anywhere
body: <p>I am relatively new to SQL (in SQL Anywhere). I tried to join two tables but always get an error</p>
  <blockquote>
  <p>SQL Anywhere Error -131: Syntax error near 'left' on line 17</p>
  </blockquote>
  <p>Is there any mistake for my left join? Thank you</p>
  <pre><code>(
  SELECT 
      Text_ID, Asdate, BigUnitCode AS Big_Code, 
      (BigUnitCode +'@'+ BigUnitName) as Main_ID, Method, xt.[Comment], 
      SUM(FIvalue) AS CurrentValue 
  FROM
      (SELECT * FROM dmf_dbo.main1
       WHERE Text_ID = 440168) AS xt
  GROUP BY 
      Text_ID, Asdate, BigUnitCode, Method, xt.[Comment], BigUnitName
  ) AS gz
  LEFT JOIN
      (SELECT
           (BigUnitCode +'@'+ BigUnitName) AS Main_ID, BigDep_code AS group_id, 
           BigDep_name AS group_name, SmallUnit_code AS sub_id, 
           SmallUnit_name AS sub_name 
       FROM
           dmf_dbo.main2 
       WHERE 
           ASOFDATE = '2020-07-11'
       GROUP BY 
           SmallUnit_code, SmallUnit_name) AS ho ON gz.Main_ID = ho.Main_ID
  </code></pre>