'Something is missing in my querie, and i feel burned [closed]

I have this complicated querie and I have to fix it, at the moment I think there is an error in the where, something will be missing there, but I am not sure, that's why I ask you for help from the powerful people of stackoverflow.

If you want it is good and without errors, that means that the error is in the data entry, and that would have an easier solution.

I definitely have to improve in consultations.

Query:

SELECT
  t.TICKET,
  t.TIPOOPERACION,
  o.DESCRIPCION_CAS AS DESCOPCAS,
  o.DESCRIPCION_CAT AS DESCOPCAT,
  o.DESCRIPCION_EN AS DESCOPEN,
  ca.ORDEN,
  t.APLORIGEN,
  t.FECHAALTA,
  t.FECHACADUCIDAD,
  t.ESTADO,
  t.OFICINA,
  t.CONTRATO,
  t.VISIBILIDAD,
  t.VISIBLECLI,
  t.RESPONSABLE,
  t.USUARIOMOD,
  t.CANAL,
  t.IDPART,
  t.DATOS,
  t.FECHAMODIFICACION,
  t.COMENTARIOS,
  t.PEA,
  t.PARAMETROSPEA,
  t.URL,
  ca.DESCRIPCION_CAS AS descCategoriaCas,
  ca.DESCRIPCION_CAT AS descCategoriaCat,
  ca.DESCRIPCION_EN AS descCategoriaEn,
  t.categoria,
  o.IMAGEN,
  t.NUM_MENSAJE,
  NVL2(t.FECHAMODIFICACION, 'S', 'N') AS LEIDO,
  t.COD_VISUALIZACION,
  t.INFO_VARIABLE,
  TRUNC(
    (
      TO_DATE(t.FECHACADUCIDAD, 'YYYYMMDD') - TO_DATE(TO_CHAR(SYSDATE, 'YYYYMMDD'), 'YYYYMMDD')
    )
  ) AS DIAS_CADUCIDAD,
  t.ID_APLICACION,
  t.HORA_CADUCIDAD,
  t.DATOS_VISUALIZACION,
  t.IMPORTE,
  t.DIVISA,
  o.OPERATIVA,
  t.LISTA_ID_GDD AS listaiddocumentos,
  t.REF_AGRUPADORA_GDD,
  T.FECHA_INICIO AS FECHAINICIO,
  TO_DATE(
    CONCAT(
      CONCAT(t.FECHACADUCIDAD, ' '),
      DECODE (t.HORA_CADUCIDAD, NULL, '23:59', t.HORA_CADUCIDAD)
    ),
    'YYYYMMDD HH24:MI'
  ) AS FECHACADUCIDADCOMPLETA,
  t.PREGUNTA_SECRETA,
  t.OPERACION_BLOQUEADA,
  t.FECHA_BLOQUEO,
  o.MINUTOS_BLOQUEO,
  t.NUMERO_EMPLEADO,
  t.NUMERO_EMPLEADO_MOD,
  t.TIPO_PERSONA,
  t.CONSOLIDA_SIN_FIRMA AS CONSOLIDARSINFIRMA,
  o.CONSOLIDAR_SIN_FIRMA AS PUEDECONSOLIDADSINFIRMA,
  o.CONSOLIDAR_CON_ERROR_FIRMA as puedeConsolidarErrorFirma,
  t.LISTA_DOC_NO_DEMORABLE AS listaDocNoDemorable,
  t.DEMORA,
  t.SUBCANAL,
  t.MONITORING_DATOS,
  (
    SELECT
      LITERAL_MOTIVO
    FROM
      TDE_MOTIVOS_ELIMINAR M
      INNER JOIN TDE_TAREAS T ON T.ID_MOTIVO_ELIMINAR = M.ID_MOTIVO
    WHERE
      TICKET = ?
  ) as motivoEliminar,
  DECODE(
    (
      SELECT
        ESTADO
      FROM
        TDE_TAREAS
      WHERE
        TICKET = ?
    ),
    4,
    'S',
    'N'
  ) AS puedeFirmar,
  t.PNOW,
  t.POFI,
  t.PARAMETROS_POFI as parametrosPOfi,
  t.LITERAL_AGRUPACION,
  DECODE (t.TICKET_ANIDADO, NULL, 'N', 'S') AS STOPANIDADO,
  t.TIPOANIDAMIENTO,
  t.TICKET_PADRE AS ticketPadre,
  t.NUEVO_CIRCUITO as nuevoCircuito,
  t.ticket_anidado as ticketAnidado,
  (
    DECODE (t.TIENE_HIJOS, NULL, 'N', t.TIENE_HIJOS)
  ) AS tieneHijos,
  o.tipoanulacion AS tipoAnulacion,
  o.eliminable,
  t.VISIBILIDAD_PERSONA AS visibilidadPer
FROM
  tde_tareas t,
  tde_operaciones o,
  tde_categoria ca
WHERE
  AND o.tipooperacion = t.tipooperacion
  AND o.categoria = t.categoria
  AND ca.categoria = t.categoria

This is the error: ORA-00936: missing expression



Solution 1:[1]

This is wrong:

WHERE
  AND o.tipooperacion = t.tipooperacion

Remove AND (or add some condition behind WHERE, if there is any you - possibly - missed or deleted).

Solution 2:[2]

You haven't joined the tables in the FROM

FROM
  tde_tareas t
  join tde_operaciones o
  on o.tipooperacion = t.tipooperacion AND o.categoria = t.categoria
  join tde_categoria ca on ca.categoria = t.categoria;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Littlefoot
Solution 2