How do I use a sub-string of a field?
You need to add an expression with SelectInterface::addExpression:

$query = $db-&gt;select('node_field_data', 'nfd')
  -&gt;fields('nfd', ['title'])
  -&gt;extend(\Drupal\Core\Database\Query\TableSortExtender::class)
  -&gt;extend(\Drupal\Core\Database\Query\PagerSelectExtender::class);

$expr_alias = $query-&gt;addExpression('SUBSTRING(title, 13, 4)', 'num');

$query-&gt;orderBy($expr_alias, 'ASC')-&gt;limit('50');