select count(*) from `sales_order_entity` AS `e` LEFT JOIN `sales_order_entity_int` AS `_table_billing_address_id` ON (_table_billing_address_id.entity_id = e.entity_id) AND (_table_billing_address_id.store_id in ('0', '1', '5', '6')) AND (_table_billing_address_id.attribute_id='217') LEFT JOIN `sales_order_entity_varchar` AS `_table_billing_firstname` ON (_table_billing_firstname.entity_id = _table_billing_address_id.value) AND (_table_billing_firstname.store_id in ('0', '1', '5', '6')) AND (_table_billing_firstname.attribute_id='224') LEFT JOIN `sales_order_entity_varchar` AS `_table_billing_lastname` ON (_table_billing_lastname.entity_id = _table_billing_address_id.value) AND (_table_billing_lastname.store_id in ('0', '1', '5', '6')) AND (_table_billing_lastname.attribute_id='225') LEFT JOIN `sales_order_entity_int` AS `_table_shipping_address_id` ON (_table_shipping_address_id.entity_id = e.entity_id) AND (_table_shipping_address_id.store_id in ('0', '1', '5', '6')) AND (_table_shipping_address_id.attribute_id='216') LEFT JOIN `sales_order_entity_varchar` AS `_table_shipping_firstname` ON (_table_shipping_firstname.entity_id = _table_shipping_address_id.value) AND (_table_shipping_firstname.store_id in ('0', '1', '5', '6')) AND (_table_shipping_firstname.attribute_id='224') LEFT JOIN `sales_order_entity_varchar` AS `_table_shipping_lastname` ON (_table_shipping_lastname.entity_id = _table_shipping_address_id.value) AND (_table_shipping_lastname.store_id in ('0', '1', '5', '6')) AND (_table_shipping_lastname.attribute_id='225') WHERE (e.entity_type_id = 4)