clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335942 fiddles created (27476 in the last week).

CREATE TABLE t ( A varchar(2), B varchar(2), C varchar(2), D timestamp, E varchar(2) ) ;
 hidden batch(es)


INSERT INTO t (`A`, `B`, `C`, `D`, `E`) VALUES ('a1', 'b1', 'c1', '2017-05-16 11:46:36', 'PA'), ('a1', 'b1', 'c1', '2017-05-16 11:46:37', 'PR'), ('a2', 'b2', 'c2', '2017-05-17 01:34:28', 'PA'), ('a3', NULL, 'c3', '2017-05-12 19:14:15', 'PA'), ('a3', 'b3', 'c3', '2017-05-12 19:14:15', 'PR'), ('a4', 'b4', 'c4', '2017-05-12 19:16:15', 'PA'), ('a4', 'b4', 'c4', '2017-05-12 23:16:15', 'PR') ;
 hidden batch(es)


SELECT A, B, C, D, E FROM t AS t0 WHERE NOT EXISTS (SELECT * FROM t AS t1 WHERE (t1.A = t0.A or t1.A is NULL or t0.A is NULL) AND (t1.B = t0.B or t1.B is NULL or t0.B is NULL) AND (t1.C = t0.C or t1.C is NULL or t0.C is NULL) AND (abs( unix_timestamp(t1.D) - unix_timestamp(t0.D) ) < 120) AND NOT (t1.E <=> t0.E) ) AND t0.E <> 'PR' ;
A B C D E
a2 b2 c2 2017-05-17 01:34:28 PA
a4 b4 c4 2017-05-12 19:16:15 PA
 hidden batch(es)