-- Clientes ha quienes se les ha vendido desde 2008

SELECT suc.nombre_sucursal AS Branch_Office,
    cs.id_cliente AS ID_Customer,
    cs.nombre_contacto AS Customer_Contact, 
    cs.nombre_cliente AS Customer_Name, 
    cs.direccion AS Address,
    CONCAT_WS(', ',z.nombre_ciudad,z.nombre_depto) AS City
FROM 
    documento_ventas dv 
    JOIN cliente_has_sucursal cs 
        ON ( dv.id_sucursal = cs.id_sucursal AND dv.id_cliente = cs.id_cliente )
    JOIN sucursal suc
        ON ( dv.id_sucursal = suc.id_sucursal )
    JOIN view_ciudades AS z
        ON (cs.ciudad = z.id_ciudad )
WHERE
    YEAR(dv.fecha) >= 2008
    AND LEFT(dv.id_documento,2) RLIKE 'F|D[^0-9MP]'
    AND NOT (dv.id_cliente LIKE "999") 
GROUP BY Branch_Office, ID_Customer
