Dies ist meine AbfrageSQL-Abfrage versuchen Verwendung DECODE in dem Oracle
SELECT *
FROM (SELECT cexp.expediente.num_expe "Num. Expediente",
cexp.expediente.cod_tipo_expe Tipo,
cexp.expediente.nif NIF, cexp.expediente.interesado "Razon Social",
MAX (DECODE (a.descripcion,
'NUMERO_FACTURA', cexp.md_valores.valor,
NULL
)
) "Numero Factura",
MAX (DECODE (a.descripcion,
'IMPORTE_FACTURA', cexp.md_valores.valor,
NULL
)
) "Importe bruto",
MAX (DECODE (a.descripcion,
'IMPORTE_NETO', cexp.md_valores.valor,
NULL
)
) "Importe neto",
MAX (DECODE (a.descripcion,
'FECHA_PRESENTACION_FACTURA', cexp.md_valores.valor,
NULL
)
) "Fecha recepcion"
FROM cexp.md_propiedades a
RIGHT JOIN
(cexp.expediente RIGHT JOIN cexp.md_valores
ON cexp.expediente.num_expe = cexp.md_valores.num_expe)
ON (a.propiedad = md_valores.propiedad)
AND (a.cod_tipo_expe = md_valores.cod_tipo_expe)
WHERE (cexp.expediente.cod_tipo_acto = '12EO' AND (cexp.expediente.cod_tipo_expe='CM11' OR cexp.expediente.cod_tipo_expe='FA11' OR cexp.expediente.cod_tipo_expe='CM08' OR cexp.expediente.cod_tipo_expe='FA09'))
GROUP BY cexp.expediente.num_expe,
cexp.expediente.interesado,
cexp.expediente.nif,
cexp.expediente.cod_tipo_expe)
Wenn ich diesen Code verwenden, habe ich nicht Problem. Dies ist das Ergebnis: The Result
Aber jetzt i enthalten muß in der WHERE-Klausel "Fecha recepcion"> '01/01/2016' AND "Fecha recepcion" < '06/06/2016' .
Kann mir dabei helfen?
Warum können Sie nicht einfach die Bedingung hinzufügen? Welches Problem hast du? – Aleksej
@Aleksej Wenn ich versuche, fügen Sie dies der Fehler ist dies: QUERY VALIDATION FEHLGESCHLAGEN: ORA-00904: "Fecha recepcion": Ungültige Kennung –
Für diejenigen, die den ask zu entschlüsseln: der Fragesteller möchte die Abfrage basierend auf dem Alias-Ergebnis von filtern die 'MAX (DECODE (...))' Funktionen. –