Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(15-1) Question 1: 1. Here is some information about the size of two tables: Table 1: 10 columns 100,000 rows Table 2: 10 columns 50,000

(15-1) Question 1: 1. Here is some information about the size of two tables: Table 1: 10 columns 100,000 rows Table 2: 10 columns 50,000 rows What is the maximum number of columns and rows of the union of these two tables? What is the maximum number of columns and rows of the inner join of the tables? 2. Write a select statement to form the union of the twos table and the threes table. (15-2) Question 2: Write a select statement to form a union of the twos table and the threes table. Use union all. How does this differ from using a regular union? (15-3) Question 3: 1. What is wrong with this select statement? select number_2 from twos union select number_3, word_3 from threes; 2. Goal 1: Show that a union is similar to an insert statement in that it can add new data to the result table. 3. Goal 2: Show a union that uses more than two select statements. The following select statement shows the number of lunches that each employee will attend, but it does not account for Carol Rose or Paula Jacobs because they are not attending any lunches. Modify this statement to show that these two people will not attend any lunches. select a.first_name, a.last_name, count(b.lunch_id) as number_of_lunches from L_EMPLOYEES a inner join L_LUNCHES b on a.employee_id = b.employee_id group by a.first_name, a.last_name; (15-4) Question 4: Modify the following union. Add an order by clause to it to sort the rows by the last name. Try all four methods. Which ones work? select a.first_name, a.last_name, count(b.lunch_id) as number_of_lunches from L_EMPLOYEES a inner join L_LUNCHES b on a.employee_id = b.employee_id group by a.first_name, a.last_name union all select 'Carol', 'Rose', 0 from dual union all select 'Paula', 'Jacobs', 0 from dual; (15-5) Question 5: Goal: Show that a union can add new rows of data to a table. This is similar to what an insert statement does. First, create a select statement that lists all the columns and rows of the L_EMPLOYEES table and uses a union all to add the following new employee. Then save the result table as a new table called sec1505_employees Employee_id: 301 First_Name: Gail Last_Name: Jones Dept_code: Sal Hire_date: Feb 15, 2011 Credit_limit: $25.00 Phone_number: (null) Manager_id: 202 (15-6) Question 6: Run the code from this section. Use the methods of section 7-12 to examine the datatypes of the columns of the beginning tables and of the new view created by the union. Have any of the datatypes changed in the process of forming the union? (15-7) Question 7: Modify the following select statement. Convert the datatypes of all the columns to text. (Actually, sometimes this code will work as it is and the conversion of the datatypes is done automatically for you behind the scenes.) select date_1, date_1, date_1 from sec1507_first union select number_2, word_2, date_2 from sec1507_second; (15-8) Question 8: Modify the following select statement to make it work. Add one more column to the second select statement. You can use either a null or a literal value. select number_1, word_1, date_1 from sec1508_more_columns union select number_2, word_2 from twos; (15-10) Question 9: The following select statement creates a union of the twos table with the threes table. Add a new column to show the table from which each row comes. select number_2, word_2 from twos union select number_3, word_3 from threes;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What is the mean world syndrome?

Answered: 1 week ago