SELECT
    v.id_venta AS 'ID VENTA',
    v.folio AS 'FOLIO',
    v.total AS 'TOTAL',
    SUM( IF( dv.id_detalle_venta IS NULL, 0, dv.monto ) ) AS 'TOTAL DETALLE',
    v.fecha AS 'FECHA',
    IF( v.facturado = 0, '0', 'Timbrada' )
FROM ec_ventas v
LEFT JOIN ec_detalle_venta dv
ON v.id_venta = dv.id_venta
WHERE ( v.fecha BETWEEN '$_FECHA_1' AND '$_FECHA_2' )
GROUP BY v.id_venta