title: QUALIFY ROW_NUMBER in teradata
body: <p>below is the oracle SQL and i want to change it in Teradata format.</p>
  
  <pre><code>SELECT branch_code,
      branch_no,
      c_no,
      cd_type
  FROM (
      SELECT branch_code,
          branch_no,
          c_no,
          cd_type,
          * * RANK() OVER (
              PARTITION BY c_no ORDER BY cd_type
              ) RANK * *
      FROM (
          SELECT branch_code,
              branch_no,
              c_no,
              MIN(cd_type) cd_type
          FROM EMPLOYEE
          WHERE S_CODE = 'C'
              AND (branch_no) NOT IN (
                  SELECT branch_code
                  FROM DEPARTMENT
                  WHERE branch_code = 'ABC'
                  )
          )
      )
  WHERE RANK = 1
  </code></pre>
  
  <p>I have used QUALIFY for RANK as below .</p>
  
  <pre><code>SELECT branch_code,
      branch_no,
      c_no,
      cd_type
  FROM (
      SELECT branch_code,
          branch_no,
          c_no,
          cd_type,
          * * QUALIFY ROW_NUMBER() OVER (
              PARTITION BY c_no ORDER BY cd_type
              ) * * RANK
      FROM (
          SELECT branch_code,
              branch_no,
              c_no,
              MIN(cd_type) cd_type
          FROM EMPLOYEE
          WHERE S_CODE = 'C'
              AND (branch_no) NOT IN (
                  SELECT branch_code
                  FROM DEPARTMENT
                  WHERE branch_code = 'ABC'
                  )
          )
      )
  WHERE RANK = 1
  </code></pre>
  
  <p>But getting error that "Expected something between , and QUALIFY.</p>
  
  <p>Can we put QUALIFY in select statement ?</p>