$sql = "SELECT *";
$sql .= ", (SELECT COUNT(*) FROM `oc_order` od WHERE od.customer_id = c.customer_id) AS orders_count";
$sql .= ", (SELECT SUM(total) FROM `oc_order` od WHERE od.customer_id = c.customer_id) AS orders_sum";
$sql .= ", (SELECT date_added FROM `oc_order` od WHERE od.customer_id = c.customer_id ORDER BY date_added DESC LIMIT 1) AS order_last";
$sql .= ", (SELECT date_added FROM `oc_order` od WHERE od.customer_id = c.customer_id ORDER BY date_added ASC LIMIT 1) AS order_first";
$sql .= ", CONCAT(c.firstname, ' ', c.lastname) AS name, cgd.name AS customer_group FROM oc_customer c LEFT JOIN oc_customer_group_description cgd ON (c.customer_group_id = cgd.customer_group_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";