SELECT DISTINCT 'log message' AS FIRST , SECOND , third , fourth

FROM schema . first_table

AND fourth IN (

SELECT fourth FROM schema . first_table

WHERE fifth = 'testA'

AND fourth IS NOT NULL AND fourth <> ''

AND fourth IN

( SELECT fourth FROM schema . first_table

WHERE fourth <> '' AND fourth IS NOT NULL

AND ( fifth IN ( 'some' , 'strings' ) )

)

AND fourth NOT IN

( SELECT fourth FROM schema . first_table

WHERE fourth <> '' AND fourth IS NOT NULL

AND ( fifth = 'testB' )

) )