db_select get value of the field
If I understood correctly, this snippet would get you the number:

use Drupal\Core\Database\Database;

$query = \Drupal::database()-&gt;select('node__field_order_reference_number', 'f');
$query-&gt;fields('f', ['field_order_reference_number_value']);
$query-&gt;orderBy("revision_id", 'DESC');
$query-&gt;range(0, 1);
$last_order_reference_number = $query-&gt;execute()-&gt;fetchCol()[0];


If you need to further understand the database schema related to your field, you could try these commands:

mysql> show tables like '%order_reference_number%';

+----------------------------------------------+
| Tables_in_drupal8 (%order_reference_number%) |
+----------------------------------------------+
| node__field_order_reference_number           |
| node_revision__field_order_reference_number  |
+----------------------------------------------+
2 rows in set (0.00 sec)


mysql> describe node__field_order_reference_number;

+------------------------------------+------------------+------+-----+---------+-------+
| Field                              | Type             | Null | Key | Default | Extra |
+------------------------------------+------------------+------+-----+---------+-------+
| bundle                             | varchar(128)     | NO   | MUL |         |       |
| deleted                            | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id                          | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id                        | int(10) unsigned | NO   | MUL | NULL    |       |
| langcode                           | varchar(32)      | NO   | PRI |         |       |
| delta                              | int(10) unsigned | NO   | PRI | NULL    |       |
| field_order_reference_number_value | varchar(255)     | NO   |     | NULL    |       |
+------------------------------------+------------------+------+-----+---------+-------+
7 rows in set (0.23 sec)


mysql> select * from  node__field_order_reference_number;

+--------+---------+-----------+-------------+----------+-------+------------------------------------+
| bundle | deleted | entity_id | revision_id | langcode | delta | field_order_reference_number_value |
+--------+---------+-----------+-------------+----------+-------+------------------------------------+
| page   |       0 |        17 |          28 | en       |     0 | 123                                |
+--------+---------+-----------+-------------+----------+-------+------------------------------------+
1 row in set (0.00 sec)