Ошибка кода SQL не соответствует вводу "из" ожидаемого - PullRequest
0 голосов
/ 19 сентября 2018

Привет ниже мой код SQL, и он дает мне ошибку, и я не знаю, почему.Если кто-нибудь может помочь.

select time_dif, count(time_dif) as count 
from 
(
select datediff(so_so_close_time,date_closed) as time_dif
from `mbg_service_prd`.`mds_service_orders_base_cdl`
inner join `mbg_service_prd`.`rnt_incident_detail_base_cdl`
on 
(srv_customer_phone = mobile_phone or srv_customer_email = email_address)
where (
(srv_customer_phone<>''or srv_customer_phone is not null)
or (srv_customer_email<>'' or srv_customer_email is not null) 
or (mobile_phone<>'' or mobile_phoneis not null) 
or (email_addressis<>'' or email_addressis not null) 
)
)
group by time_dif
order by time_dif

Это дает мне сообщение об ошибке: org.apache.spark.sql.catalyst.parser.ParseException: несоответствующий ввод 'из' ожидающих {, 'ГДЕ', 'ГРУППА', 'ЗАКАЗАТЬ', 'HAVING ',' LIMIT ',' LATERAL ',' WINDOW ',' UNION ',' EXCEPT ',' INTERSECT ',' SORT ',' CLUSTER ',' DISTRIBUTE '} (строка 3, позиция 0)

Ответы [ 2 ]

0 голосов
/ 19 сентября 2018

В функции datediff произошла ошибка.Мы используем три параметра в датированном формате: интервал, дата1, дата2.DATEDIFF (интервал, дата1, дата2).

0 голосов
/ 19 сентября 2018

Попробуйте с приведенным ниже запросом

select a.time_dif, count(a.time_dif) as time_dif_count 
from 
(
select datediff(day,so_so_close_time,date_closed) as time_dif
from mbg_service_prd.mds_service_orders_base_cdl
inner join mbg_service_prd.rnt_incident_detail_base_cdl
on 
(srv_customer_phone = mobile_phone or srv_customer_email = email_address)
where (
(srv_customer_phone <> '' or srv_customer_phone is not null)
or (srv_customer_email <> '' or srv_customer_email is not null) 
or (mobile_phone <> '' or mobile_phone is not null) 
or (email_address <> '' or email_address is not null) 
)
)a
group by a.time_dif
order by a.time_dif
...