###### ###MONTOS CON PUNTOS (antiguo proceso): SELECT p.idresto, p.name_resto RESTAURANTE_NAME, CASE p.end_trial when 0 then 'PAY' when 1 then 'SEP UP' when 2 then 'TRIAL' END as STATUS, t.type_pay as TYPE_PAY, CONVERT(m.total,DECIMAL(11,2)) as INVOICE, CONVERT((SELECT b.total FROM procesin_master as b WHERE b.idproces=(m.idproces-1) and b.idresto=m.idresto and b.idbrach=m.idbrach),DECIMAL(11,2)) as PREVIOUS_INVOICE, (CONVERT(m.total,DECIMAL(11,2)) - CONVERT((SELECT b.total FROM procesin_master as b WHERE b.idproces=(m.idproces-1) and b.idresto=m.idresto and b.idbrach=m.idbrach),DECIMAL(11,2))) as DIFFERENCE_INVOICE, m.qty_ord as QTY_ONLINE_ORDERS, (select c.qty_ord FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach) as PREVIOUS_QTY_ONLINE_ORDERS, (m.qty_ord - (select c.qty_ord FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach)) as DIFFERENCE_QTY_ONLINE_ORDERS, m.qty_call as QTY_PHONE_ORDERS, (select c.qty_call FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach) as PREVIOUS_QTY_PHONE_ORDERS, (m.qty_call - (select c.qty_call FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach)) as DIFFERENCE_QTY_PHONE_ORDERS, b.phone1 AS PHONE, b.postalcode AS POST_CODE, b.address_show AS RESTAURANT_ADDRESS, a.owner_name AS NAME_OWNER, p.invoiceid, IFNULL(s.name,'') as seller FROM proces_resto AS p INNER JOIN procesin_master AS m ON ( m.invoice = p.invoiceid AND m.idbrach = p.idbranch ) INNER JOIN restaurants AS r ON p.idresto = r.id LEFT JOIN branches as b ON m.idbrach = b.id LEFT JOIN resto_accounts AS a ON (a.restoid = p.idresto AND p.idbranch = a.blanch_id) LEFT JOIN sellers as s ON a.sellerid=s.id LEFT JOIN type_payinbox AS t ON t.id=m.type_pay where p.idproces=83 order by INVOICE DESC ###### ###MONTOS CON COMAS: SELECT p.idresto, p.name_resto RESTAURANTE_NAME, CASE p.end_trial when 0 then 'PAY' when 1 then 'SEP UP' when 2 then 'TRIAL' END as STATUS, t.type_pay as TYPE_PAY, REPLACE(CAST(CONVERT(m.total,DECIMAL(11,2)) AS CHAR), '.', ',') as INVOICE, REPLACE(CAST(CONVERT((SELECT b.total FROM procesin_master as b WHERE b.idproces=(m.idproces-1) and b.idresto=m.idresto and b.idbrach=m.idbrach),DECIMAL(11,2)) AS CHAR), '.', ',') as PREVIOUS_INVOICE, REPLACE(CAST((CONVERT(m.total,DECIMAL(11,2)) - CONVERT((SELECT b.total FROM procesin_master as b WHERE b.idproces=(m.idproces-1) and b.idresto=m.idresto and b.idbrach=m.idbrach),DECIMAL(11,2))) AS CHAR), '.', ',') as DIFFERENCE_INVOICE, m.qty_ord as QTY_ONLINE_ORDERS, (select c.qty_ord FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach) as PREVIOUS_QTY_ONLINE_ORDERS, (m.qty_ord - (select c.qty_ord FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach)) as DIFFERENCE_QTY_ONLINE_ORDERS, m.qty_call as QTY_PHONE_ORDERS, (select c.qty_call FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach) as PREVIOUS_QTY_PHONE_ORDERS, (m.qty_call - (select c.qty_call FROM procesin_master as c WHERE c.idproces=(m.idproces-1) and c.idresto=m.idresto and c.idbrach=m.idbrach)) as DIFFERENCE_QTY_PHONE_ORDERS, b.phone1 AS PHONE, b.postalcode AS POST_CODE, b.address_show AS RESTAURANT_ADDRESS, a.owner_name AS NAME_OWNER, p.invoiceid, IFNULL(s.name,'') as seller FROM proces_resto AS p INNER JOIN procesin_master AS m ON ( m.invoice = p.invoiceid AND m.idbrach = p.idbranch ) INNER JOIN restaurants AS r ON p.idresto = r.id LEFT JOIN branches as b ON m.idbrach = b.id LEFT JOIN resto_accounts AS a ON (a.restoid = p.idresto AND p.idbranch = a.blanch_id) LEFT JOIN sellers as s ON a.sellerid=s.id LEFT JOIN type_payinbox AS t ON t.id=m.type_pay where p.idproces=86 order by INVOICE DESC