Hi, I'm just a user and I had this query programmed by a friend and seems to have stop working.
The error message I get says that the error is near the CASE WHEN statement at line 8. Any comments are welcomed and if possible suggestions to correct the error.
The error message I get says that the error is near the CASE WHEN statement at line 8. Any comments are welcomed and if possible suggestions to correct the error.
Code:
Select vendor,F.airline_code,F.invoice_nmr invoice_vendor,F.booking_nmr, sum(amount) total_factura , IF(tipo = 'CH',facturado,pagado) monto_pagado,tipo, concat(b_month,'-',b_year) periodo_factura,F.fecha_carga,date awb_date,count(*) Reg from p24l3dbd_costos.PAGOS G RIGHT JOIN p24l3dbd_costos.FACTURAS F ON F.booking_nmr = G.booking_nmr and F.airline_code = G.airline_code LEFT JOIN p24l3dbd_costos.GUIAS_ID I ON F.booking_nmr = I.booking_nmr and F.airline_code = I.id_ch group by F.airline_code,F.invoice_nmr,F.booking_nmr,F.fecha_carga order by F.select *, CASE WHEN vendor is null THEN 'Sin Guia' ELSE 'Con Guia' END estado_factura, CASE WHEN dif <=-5 or vendor is null THEN 'A Disputar' ELSE 'A Pagar' END pagar from (Select vendor ,airline_code ,invoice_nmr invoice_vendor,F.booking_nmr,date awb_date,F.ori,F.dest ,accrual_cost provision ,pagado total_pagado,facturado total_facturado, IF(G.tipo='CH',(accrual_cost-pagado),(accrual_cost-pagado-sum(amount))) dif, sum(amount) ultima_factura ,nmr_pago ,weight vendor_chw,booking_chw awb_chw,spotref, concat(substring(billing_per_begin,1,2),'-',substring(billing_per_begin,9,2)) periodo_guia, concat(b_month,'-',b_year) periodo_factura,tipo,fecha_carga from p24l3dbd_costos.GUIAS_ID G RIGHT JOIN p24l3dbd_costos.FACTURAS F ON F.booking_nmr = G.booking_nmr and F.airline_code = G.id_ch group by F.airline_code,F.invoice_nmr,F.booking_nmr,fecha_carga) x order by vendor, (str_to_date(fecha_carga,'%m/%d/%Y')) DESC, vendor desc
Comment