Using QMF

Example 3

This query lists employees whose salaries are greater than their managers' salaries. Another version of this query that is shown in Example 1 selects twice from Q.STAFF without using a subquery. A query that joins two or more tables will probably run faster than a similar query that uses a subquery.

SELECT ID, NAME, SALARY
  FROM Q.STAFF EMP
  WHERE SALARY > (SELECT SALARY
    FROM Q.STAFF
    WHERE ID = (SELECT MANAGER
                FROM Q.ORG
                WHERE DEPTNUMB = EMP.DEPT))


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]