Previous Topic: Comparison Operators and Keywords in PredicatesNext Topic: Exercise 4-1


Using Comparison Operators in Predicates

The search value in the predicate can be:

You can also use two column names in a predicate (for example, vac_taken <= vac_accrued).

The column name you use in the WHERE clause need not appear in the SELECT column list.

How It's Done

The Human Resources department needs to see a list of all employees and the number of vacation hours they have accrued in 1999. The BENEFITS table contains this information. Enter:

select emp_id, vac_accrued
       from benefits
       where fiscal_year = 2000;

The result looks like this:

EMP_ID  VAC_ACCRUED ------  -----------   3411        68.00   4773        68.00   2010        92.75   3338        68.00   2246        92.50   1034        92.50   2424        92.50   3767        68.00   3449        68.00   3082        68.00   3341        68.00   4660        68.00   2209        92.50   2894        68.00   4001        68.00   5090        46.00   1765        92.50   4456        68.00   3991        68.00   3778        68.00   4358        68.00   4962        68.00   2180        92.50   2106        92.50   3222        68.00   4002        68.00   2437        68.00   2096        92.50   2004        92.50   5103        46.00   5008        46.50   4321        68.00   2598        60.00   3764        68.00   2448        68.00   2461        68.00   1003        92.00   1234        92.00   4027        68.00   2466        92.50   2174        92.00   2781        68.00   3704        68.00   4008        68.00   3433        68.00   3288        68.00   3841        68.00   4703        46.75   3294        68.00   3769        68.00   3118        68.00 51 rows processed