Hey guys!
My query is bugging! I just want to filter both numbers 4410 and 4412 within this time range. I have to use TRIM before because this field has some whitespaces.
Is there any way to fix this?
select SDBANCO.VCC_API_EXTRATO_INTERNO.AGENCIA,
SDBANCO.VCC_API_EXTRATO_INTERNO.NUM_CONTA,
SDBANCO.VCC_API_EXTRATO_INTERNO.NUM_CONTA_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.PRIMEIRO_TITULAR,
SDBANCO.VCC_API_EXTRATO_INTERNO.NOME,
SDBANCO.VCC_API_EXTRATO_INTERNO.DOCUMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.TIPO_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANC_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.DT_LANCAMEN_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DESC_HISTORICO_SEM_COMPLEMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.INSCRICAO,
SDBANCO.VCC_API_EXTRATO_INTERNO.VALOR,
SDBANCO.VCC_API_EXTRATO_INTERNO.TIPO_CC,
SDBANCO.VCC_API_EXTRATO_INTERNO.ID_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.CPF_CNPJ_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.DESC_HISTORICO
from SDBANCO.VCC_API_EXTRATO_INTERNO
where (SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANCAMENTO Between To_Date('15/06/2022', 'DD/MM/YYYY') and To_Date('17/06/2022', 'DD/MM/YYYY') and Trim(SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO) = '4412' and Trim(SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO) = '4410'
Solved! Go to Solution.
@Joker_Hazard are they actually numerical fields? If so you may need to wrap the field you get the numbers from in STR() as trim is a string function as far as I’m aware.
Hello @Joker_Hazard, could you try removing the highlighted red part?
select SDBANCO.VCC_API_EXTRATO_INTERNO.AGENCIA,
SDBANCO.VCC_API_EXTRATO_INTERNO.NUM_CONTA,
SDBANCO.VCC_API_EXTRATO_INTERNO.NUM_CONTA_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.PRIMEIRO_TITULAR,
SDBANCO.VCC_API_EXTRATO_INTERNO.NOME,
SDBANCO.VCC_API_EXTRATO_INTERNO.DOCUMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.TIPO_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANC_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.DT_LANCAMEN_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DESC_HISTORICO_SEM_COMPLEMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.INSCRICAO,
SDBANCO.VCC_API_EXTRATO_INTERNO.VALOR,
SDBANCO.VCC_API_EXTRATO_INTERNO.TIPO_CC,
SDBANCO.VCC_API_EXTRATO_INTERNO.ID_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANCAMENTO,
SDBANCO.VCC_API_EXTRATO_INTERNO.CPF_CNPJ_FORMAT,
SDBANCO.VCC_API_EXTRATO_INTERNO.DESC_HISTORICO
from SDBANCO.VCC_API_EXTRATO_INTERNO
where (SDBANCO.VCC_API_EXTRATO_INTERNO.DATA_LANCAMENTO Between To_Date('15/06/2022', 'DD/MM/YYYY') and To_Date('17/06/2022', 'DD/MM/YYYY') and Trim(SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO) = '4412' and Trim(SDBANCO.VCC_API_EXTRATO_INTERNO.ID_HISTORICO) = '4410'
Thanks!
Hey. They are actually string fields. For some reason this database translated those INT to strings. If I filter only 4412 for example, the query works.
True! For some reason Alteryx put ( right there. Very interesting, I did not pay attention to that. Thanks