Checking whether rows that satisfy certain conditions exist
The EXISTS predicate can be specified in a subquery. Whether rows are specified depends on whether or not the
result of the subquery is null. In other words, the EXISTS predicate is used when the row count for the table derived
from the result of the subquery can be 0. If the result of the subquery specified after EXISTS is not null, the EXISTS
predicate is true. If the result of the subquery is null, the EXISTS predicate is false.
The format of the subquery specification in parentheses is the same as that for a query specification. The result of the
subquery can be a table with two or more columns. The following is an example of specifying the EXISTS predicate:
Example 4:
In this example, data for ITMNO and PRODUCT for products for which the value of orders is greater
than 5,000,000 is fetched. The value of orders is obtained by PRICE x ORDERQTY.
99