Zend certified PHP/Magento developer

customer_id = NULL in sales_order table?

I need to get orders data directly from database. I have got all orders (about 18,000) since January 2020. I need to do a join to customer_entity however, I realized that about 300 records were missing.

By investigating further, I found out that customer_id value is null for most of the records. Some records which do have customer_id column set but shipping address id fields are null. These latter occur for orders in processing status.

Most curious is the null value in customer_id column of some orders, even in orders in complete status.

For the query, I need to join customers table so it is not an option to get all data from sales_order table.

Any help? Thanks

Jaime