title: Length of VARCHAR in Teradata
body: <p>I'm trying to write a query that only includes customer numbers either six or seven digits long. The numbers are stored in a VARCHAR(30) field in Teradata. I've tried the following:</p>
  
  <pre><code>...
  AND LENGTH(STAFF_NO) &gt; 5
  AND LENGTH(STAFF_NO) &lt; 8
  ...
  </code></pre>
  
  <pre><code>...
  AND CHARACTER_LENGTH(STAFF_NO) &gt; 5
  AND CHARACTER_LENGTH(STAFF_NO) &lt; 8
  ...
  </code></pre>
  
  <pre><code>...
  AND CHAR_LENGTH(STAFF_NO) &gt; 5
  AND CHAR_LENGTH(STAFF_NO) &lt; 8
  ...
  </code></pre>
  
  <p>but all of these have returned no rows; the query, in each case, has only looked at the maximum length of the field (30) rather than the actual number of characters in it.</p>
  
  <p>How can I filter so it only checks the number of <em>actual</em> characters in the field?</p>