--Given something like this: select a, b, c, d, e, f, g, mod(a,c) md, substr(c,1,8) from mytable where a = b and b = c and e not in (f,g) and (d is null or e is not null); --I want to get this: SELECT a, b, c, d, e, f, g, mod(a, c) md, SUBSTR(c, 1, 8) FROM mytable WHERE a = b AND b = c AND e NOT IN(f, g) AND (d IS NULL OR e IS NOT NULL); --The closest I could get is: SELECT a, b, c, d, e, f, g, mod(a, c) md, SUBSTR(c, 1, 8) FROM mytable WHERE a = b AND b = c AND e NOT IN(f, g) AND(d IS NULL OR e IS NOT NULL) ; --...Which looks "somewhat" different.