title: Convert Access Left & Mid to SQL
body: <p>I am currently trying to convert this query from Access into proper SQL.
  The Left and Mid functions in the statement have me kind of baffled.</p>
  
  <pre><code>SELECT 
  name, 
  entnum
  
  IIf(Left(Mid([entnum],4,3),1)=0,Mid([entnum],5,2),Mid([entnum],4,3)) as AGENCYCODE
  
  FROM CUSTFILE 
  </code></pre>
  
  <p>the entnum field's type is <code>varchar 15</code></p>
  
  <p>Any help with trying to understand this would be greatly appreciated.</p>