title: SQL code error mismatched input 'from' expecting
body: <p>Hi below is my SQL code and it gives me error and I do not know why. If anyone can help. </p>
  
  <pre><code>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&lt;&gt;''or srv_customer_phone is not null)
  or (srv_customer_email&lt;&gt;'' or srv_customer_email is not null) 
  or (mobile_phone&lt;&gt;'' or mobile_phoneis not null) 
  or (email_addressis&lt;&gt;'' or email_addressis not null) 
  )
  )
  group by time_dif
  order by time_dif
  </code></pre>
  
  <p>It gives me error says:
  org.apache.spark.sql.catalyst.parser.ParseException: 
  mismatched input 'from' expecting {, 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LATERAL', 'WINDOW', 'UNION', 'EXCEPT', 'INTERSECT', 'SORT', 'CLUSTER', 'DISTRIBUTE'}(line 3, pos 0)</p>