Just write in SQL what you are writing in English.
SELECT file-id -- i have to choose a record say file-id from
this table
, start-date -- i will fetch some other fields for it say
start-date
, batch-no -- and batch-no
FROM XYZ A -- i have one table say XYZ
WHERE acct-id = 'abc' -- having certain matching criteria say
acct-id = 'abc'
and cent-id = 'def' -- and cent-id = 'def'
AND NOT EXISTS -- (i have to check in the same table that) no
record exist
(SELECT *
FROM XYZ B -- i have to check in the same table
WHERE b.file-id = a.file-id -- for the same file-id
AND acct-id = 'pqr' -- with say acct-id = 'pqr'
and cent-id = 'mnp' -- and cent-id= 'mnp'
AND b.start-date = a.start-date -- for the same start date
AND b.batch-no = a.batch-no -- and same batch no
) |