-1
I’d like some help. I have the following query below, however, I need that in the DE column bring only the texts after the word "Exclusion", and in the PARA column bring only the text from the word "Inclusion". However, today he is bringing the whole text and I need only what comes "Exclusion: XXXXXXX " and "Inclusion: YYYYY".
You are loading the whole line and you are not respecting the limit that was created.
Code:
SELECT
"DATA",
CONTRATO,
TIPO_CONTRATO,
STATUS_CONTRATO,
MODALIDADE_FATURAMENTO,
PROMOCAO,
SUBSTR(observacao,INI) AS DE,
SUBSTR(observacao2,LM) AS PARA,
LOGIN,
USUARIO,
AREA
FROM
(SELECT
BASE.*,
INSTR(observacao2,' Inclusão: ',1) as LM,
INSTR(observacao2, ' Exclusão: ',1) as ini
FROM
(
SELECT
"ID",
A."DATA",
A.CONTRATO,
NUMERO_CONTRATO,
ACAO,
DESCRICAO_ACAO,
OBSERVACAO,
NUMERO_PROTOCOLO,
LOGIN,
USUARIO,
A.AREA,
B.PROMOCAO,
TIPO_CONTRATO,
STATUS_CONTRATO,
MODALIDADE_FATURAMENTO,
replace (replace(a.OBSERVACAO,'Inclusão:',' Inclusão:'),'Exclusão:',' Exclusão: ') as observacao2
from DBMDTH.vm_dth_notas_contrato A, DBMDTH.VM_DTH_USUARIO_APLICA_PROMOCAO B, DBMDTH.VM_DBM_CONTRATO E where A."DATA" BETWEEN '01/07/18' and '31/07/18'
Can help?
I think you are missing some parentheses in your SQL query. The way it is built it is very difficult to see what it is supposed to return!
– João Martins