Now You Try It
Human Resources is doing a salary comparison and needs some information on jobs, employees, and salaries. They have asked you to show them all employees whose salary is between $20,000 and $35,000.
What table holds this information?
The information is stored in the POSITION table.
Enter the appropriate SELECT statement.
The result looks like this:
JOB_ID EMP_ID SALARY_AMOUNT ------ ------ ------------- 2077 3338 22048.84 2077 2246 29536.00 3333 4660 24000.00 3333 3991 27976.00 3333 4962 30680.00 2077 2106 23920.00 4012 4002 28601.80 3333 3764 28912.00 3333 4027 28081.40 3333 3704 22880.00 3333 4008 24441.00 4012 3841 33800.00 2077 4703 24857.00 13 rows processed
If your results do not match what you see above, check Review Answers for Chapter 4 for the correct SQL syntax. Remember that result tables may be shortened in this guide.
Use NOT BETWEEN to retrieve all rows that do not fall into the specified range.
IN Predicate
You can compare a value to a list of values using the IN predicate.
How It's Done
Human Resources needs to identify employees who reside in three communities for potential car pooling. To do this, enter:
select emp_id, city
from employee
where city in ('Camden', 'Brookline', 'Canton');
Enclose the list of values in parentheses and separate values with a comma.
The result looks like this:
EMP_ID CITY ------ ---- 2299 Canton 3338 Canton 3082 Camden 4660 Camden 2209 Brookline 5090 Canton 3222 Brookline 2096 Brookline 5103 Brookline 5008 Brookline 2598 Camden 3764 Brookline 1234 Brookline 2174 Brookline 4008 Brookline 4703 Brookline 3294 Brookline 3118 Canton 18 rows processed
|
Copyright © 2014 CA.
All rights reserved.
|
|