Exists

Description: Sample of the use of ‘EXISTS’ clause in SQL

 SELECT SUBSTR(trx_number,1,10), SUBSTR(trx_type,1,8),
  SUBSTR(line_amount,1,8), SUBSTR(line_number,1,8)
   FROM ar_invoice_interface_lines a
WHERE EXISTS (SELECT 'x' FROM ar_invoice_interface_headers ah
  WHERE ah.trx_number = a.trx_number
 AND ah.status = 'Error 114')
AND a.ROWID > (SELECT MIN(b.ROWID) FROM ar_invoice_interface_lines b
      WHERE a.trx_number = b.trx_number)
/

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.