473,509 Members | 4,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error 1064 have detected on a Case When statement, please help

1 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. Select vendor,F.airline_code,F.invoice_nmr invoice_vendor,F.booking_nmr,
  2. sum(amount) total_factura  , IF(tipo = 'CH',facturado,pagado) monto_pagado,tipo,
  3. concat(b_month,'-',b_year) periodo_factura,F.fecha_carga,date awb_date,count(*) Reg
  4. from p24l3dbd_costos.PAGOS G
  5. RIGHT  JOIN p24l3dbd_costos.FACTURAS F ON  F.booking_nmr = G.booking_nmr and F.airline_code = G.airline_code 
  6. LEFT JOIN  p24l3dbd_costos.GUIAS_ID I ON  F.booking_nmr = I.booking_nmr and F.airline_code = I.id_ch
  7. group by F.airline_code,F.invoice_nmr,F.booking_nmr,F.fecha_carga
  8. order by F.select *, CASE   
  9. WHEN vendor is null THEN 'Sin Guia' ELSE 'Con Guia' END estado_factura,
  10. CASE  WHEN dif <=-5 or vendor is null THEN 'A Disputar' ELSE 'A Pagar' END pagar
  11. from (Select vendor ,airline_code ,invoice_nmr invoice_vendor,F.booking_nmr,date awb_date,F.ori,F.dest ,accrual_cost provision
  12. ,pagado total_pagado,facturado total_facturado,
  13. IF(G.tipo='CH',(accrual_cost-pagado),(accrual_cost-pagado-sum(amount))) dif,
  14. sum(amount) ultima_factura ,nmr_pago ,weight vendor_chw,booking_chw awb_chw,spotref,
  15. concat(substring(billing_per_begin,1,2),'-',substring(billing_per_begin,9,2)) periodo_guia,
  16. concat(b_month,'-',b_year) periodo_factura,tipo,fecha_carga
  17. from p24l3dbd_costos.GUIAS_ID G
  18. RIGHT  JOIN p24l3dbd_costos.FACTURAS F 
  19. ON  F.booking_nmr = G.booking_nmr and F.airline_code = G.id_ch
  20. group by F.airline_code,F.invoice_nmr,F.booking_nmr,fecha_carga) x
  21. order by vendor, (str_to_date(fecha_carga,'%m/%d/%Y')) DESC, vendor desc
Jul 16 '14 #1
1 1134
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code or formatted data.

You're saying this used to run? That can't be, it looks like you have 2 different queries running into each other on line 8.
Jul 16 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1193
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
3
43152
by: Tim Reynolds | last post by:
I support a .Net application running on a SERVER accessing MF Db2 data. Occasionally, we have some type of connection problem that we have been unable to debug up to this point. We typically...
1
2348
amitpatel66
by: amitpatel66 | last post by:
Hi, Is PLSQL Anonymous block allowed in CASE WHEN statement when CASE is used in SELECT statement. Check below code which executes but does not return anything: SELECT job, CASE WHEN job =...
4
3877
by: laurenquantrell | last post by:
Is there an equivalant construction to the CASE WHEN statement that can be used in the WHERE clause? For example, this works: SELECT FirstName = CASE WHEN c.FirstName = 'Bob' THEN 'Robert'...
3
2917
by: dipperdan | last post by:
Hi, I'm getting an error 1064 when trying to delete some rows from a table. SQL is: DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1; DELETE FROM images WHERE image_id =...
2
2565
by: Anthony97 | last post by:
Has anyone worked with multiple case when comments? I converted a query from access 07 to SQL Server 2005. Initially the query was using IIf instead of CASE WHEN. Any help or examples is greatly...
3
4939
by: phobia1 | last post by:
Hi once again. We have just changed our ISP and things that worked fine now do not, Obviously its in the differences of MYSQL and PHP versions. Have fixed most of the problems but this UPDATE...
1
1644
by: Charles Ndethi | last post by:
Hi I want to set the session id to a value after evaluating the request_time using a case when statement. here 's the table userinput_id session_id request_time ...
0
1320
by: drvcm | last post by:
Hello everyone and thank you in advance, This is been driving me crazy, in running the following query, I get the error 1064, below please find the full query and the error message. There must be...
1
1884
by: Mani Raja | last post by:
When I execute the below query im getting the following error Msg 102, Level 15, State 1, Line 13 Incorrect syntax near ')'. Any one please give a solution to solve this. In the below query...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.