Confusion in Informix when selecting dates with JOIN
0
votes
0
answers
390
views
I am trying to run a query in
Informix
, doing a join in a table of logs where we save the record of insertion of the rows.
Notice that the query below brings two results, with different insertion dates:
select * from log_cipessoa where cgccpf = 1541247000188
Results:
cgccpf tppessoa tp_dml dt_insercao
------------- -------- ------ ---------------------
1541247000188 1 INSERT 2018-03-06 15:05:42.0
1541247000188 2 INSERT 2018-03-27 09:54:45.0
Now, I want to bring the rows that were inserted after the 2018-03-21
day, but while doing the join, informix seems to merge the dt_insercao
column with the most recent date.
And according to the log above, Informix should only return the second line, where the column tppessoa
with the value 2 and dt_insercao
2018-03-27 09:54:45.0
SELECT pe.cgccpf
,pe.tppessoa
,REPLACE(LTRIM(RTRIM(pe.nomepessoa)), ' ', ' ') AS nomepessoa
,lg.dt_insercao
FROM CIPESSOA pe
INNER JOIN LOG_CIPESSOA lg
ON lg.cgccpf = pe.cgccpf
WHERE lg.tp_dml = 'INSERT'
AND lg.dt_insercao > '2018-03-21 20:09:32' AND lg.dt_insercao <= '2018-03-31 20:00:00'
and pe.cgccpf = 1541247000188 --FILTER ONLY FOR DEMONSTRATION
Results:
cgccpf tppessoa nomepessoa dt_insercao
------------- -------- ----------- ---------------------
1541247000188 1 XPTO LTDA 2018-03-27 09:54:45.0
1541247000188 2 XPTO LTDA 2018-03-27 09:54:45.0
Asked by Rafael Lima
(523 rep)
Mar 31, 2018, 07:49 PM