title: Snowflake Substring Concat Issue: Numeric value '' is not recognized
body: <p>Have a fiscal quarter column, and I want to add a column that displays the previous quarter in the same row.  I've done this successfully in tableau with logic like below.</p>
  <pre><code>IF RIGHT([current_qtr], 1) = &quot;1&quot;
  THEN LEFT([current_qtr],2)+ STR(INT(MID([current_qtr], 3,2)) -1) +&quot;Q4&quot;
  ELSE LEFT([current_qtr],5)+ STR(INT(RIGHT([current_qtr],1)) -1)
  END
  </code></pre>
  <p>Example of expected output in snowflake</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>current_qtr</th>
  <th>previous_qtr</th>
  <th>other columns</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>FY21Q1</td>
  <td>FY20Q4</td>
  <td>etc</td>
  </tr>
  <tr>
  <td>FY21Q2</td>
  <td>FY21Q1</td>
  <td>etc</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>When I try to do this in snowflake though I keep getting this &quot;Numeric value '' is not recognized error instead.  Any ideas how to fix?  Below is what I attempted.</p>
  <pre><code>SELECT *,
  CASE 
     WHEN SUBSTR(p.current_qtr,5,1) = 1 
        THEN SUBSTR(p.current_qtr,1,2) || TRY_CAST(SUBSTR(p.current_qtr,3,2) as INTEGER)-1 || 'Q4'
        ELSE SUBSTR(p.current_qtr,5,1) || TRY_CAST(SUBSTR(p.current_qtr,3,2) as INTEGER)-1
     End As prev_qtr
     FROM table as p 
  </code></pre>