Monday, April 10, 2006

SECTION 3 LESSON 3
1. Create a join based on the cost of the event between the DJs on Demand tables D_EVENTS and D_PACKAGES. Show the name of the event and the code for each event.

---- select de.name,dp.code
from d_events de, d_packages dp
where de.cost between dp.low_range and dp.high_range;

2. Using the Oracle database, create a query that returns the employee last name, salary, and job-grade level based on the salary. Select the salary between the lowest and highest salaries.

----select e.last_name,e.salary, jg.grade_level
from employees e, job_grades jg
where salary between lowest_sal and highest_sal

3. What condition requires creation of a nonequijoin?

---- Since there is no exact match between the two columns in each table.

4. Rewrite the following nonequijoin statement using the logical condition operators (AND, OR, NOT):
WHERE a.ranking BETWEEN g.lowest_rank AND g.highest_rank

----ranking >= g.lowest_rank and <= g.highest_rank

5. How do you know when to use a table alias and when not to use a table alias?

----the column is so long, and the column has to be used many times

6. What is the purpose of the WHERE clause in a join?

----provide the condition

7. What kind of join would you use if you wanted to find data between a range of numbers?

----nonequijoin

8. What kind of join would you use if you wanted to join two tables on any rows that have the same name and the same data type.

----equijoin