Question

In: Computer Science

Write a SELECT statement that returns these columns using a JOIN of three tables: order_date from...

  1. Write a SELECT statement that returns these columns using a JOIN of three tables:
    1. order_date from the orders table
    2. shipped_date from the orders table
    3. order_qty from the order_details table
    4. title from the items table
    5. artist from the items table
    6. unit_price from the items table
    7. Result table should be in order of order_date in ascending order

Solutions

Expert Solution

According to the question the order and items table has m:n cardinality.

Let the primary key of Order table (Order_ID) be treated as the foreign key in Order_item table, and similarly the primary key of Item table (Item_ID) be treated as the foreign key in Order_item table.

The SQL query is as follows:-

SELECT order_date, shipped_date, order_qty, title, artist, unit_price FROM orders o INNER JOIN order_details od on o.Order_ID = od.Order_ID INNER JOIN items i on i.Item_ID = od.Item_ID order by order_date;

The above query will select the column order_date, shipped date from order table, order_qty from order_details and title, artist, and unit_price from items table respectively then first merge the table orders and order_details and filter the records upon condition orders.Order_ID = order_details.Order_ID

Then again merge the intermediate result and the items table and filter the records upon condition items.Item_ID = order_details.Item_ID, at last sort the records in ascending order in terms of order_date.


Related Solutions

In SQL we are working with functions 1. Write a SELECT statement that returns these columns...
In SQL we are working with functions 1. Write a SELECT statement that returns these columns from the Instructors table: a. The AnnualSalary column b. A column named MonthlySalary that is the result of dividing the AnnualSalary column by 12 c. A column named MonthlySalaryRounded that calculates the monthly salary and then uses the ROUND function to round the result to 2 decimal places 2. Write a SELECT statement that returns these columns from the Students table: a. The EnrollmentDate...
A. Rewrite the query select * from section natural join classroom without using a natural join...
A. Rewrite the query select * from section natural join classroom without using a natural join but instead using an inner join with a using condition. B. Explain the difference between integrity constraints and authorization constraints.
/*explain */ Select * From Student join enrollment on student.ID = enrollment.Student_ID             join section on...
/*explain */ Select * From Student join enrollment on student.ID = enrollment.Student_ID             join section on section.ID = enrollment.section_ID             join department on major = department.name             join faculty on faculty.id = section.faculty_ID             join address on address.id = student.address_ID             join Course on section.course_Number = course.course_number and section.dept_id = course.dept_ID Where --we want to make sure we have name information for students if we want to reach out to them Student.Name_Last Not Like ('') -- the theater department has...
You can join tables using the WHERE clause, the EXISTS operator, or the IN clause. Which...
You can join tables using the WHERE clause, the EXISTS operator, or the IN clause. Which one is the easiest for you to understand? Why? The OR and AND operators are used in compound conditions. Is there any relationship between these operators and the ALL and ANY operators?
Rewrite the following SELECT statement. In the rewrite change the join operator style on the Facility...
Rewrite the following SELECT statement. In the rewrite change the join operator style on the Facility table to a Type I nested query. (10 points) SELECT eventplan.planno, eventrequest.eventno, workdate,activity FROM eventrequest, eventplan, Facility WHERE eventplan.workdate BETWEEN '2018-12-01' AND '2018-12-31' AND eventrequest.eventno = eventplan.eventno AND EventRequest.FacNo = Facility.FacNo AND facname = 'Basketball arena'; Rewrite the following SELECT statement. In the rewrite change the join operator style on the Facility and Employee tables to a Type I nested queries. (15 points) SELECT...
Can you please implement this in Oracle sql Write a SELECT statement that returns one row...
Can you please implement this in Oracle sql Write a SELECT statement that returns one row for each customer that has orders with these columns: The email_address from the Customers table A count of the number of orders The total amount for each order (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.) Return only those rows where the customer has more than 1 order. Sort the result set in descending sequence by the sum...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns...
Create a table in SQL with foreign key reference: 1.Create the three tables without any columns 2.Alter the tables to add the columns 3.Alter the tables to create the primary and foreign keys
Write an IT professional statement of purpose from using the following skill and expertise: FROM LEADERSHIP,...
Write an IT professional statement of purpose from using the following skill and expertise: FROM LEADERSHIP, PROJECT MANAGEMENT, COMPUTER REPAIR, NETWORKING, INFORMATION TECHNOLOGY INSURANCE AND MANAGEMENT, CYBRSECURITY)
The Income Statement and Balance Sheet columns below are from the work sheet of the Mandle...
The Income Statement and Balance Sheet columns below are from the work sheet of the Mandle Company for the year ended December 31, 20--. Mandle Company Work Sheet (partial) For the year ended December 31, 20-- Income Statement Balance Sheet Account Title Debit Credit Debit Credit Cash 24,000 Accounts Receivable 12,500 Merchandise Inventory 8,000 Store Supplies 550 Office Supplies 1,200 Prepaid Insurance 750 Store Equipment 33,000 Accumulated Depreciation—Store Equipment 19,000 Office Equipment 9,000 Accumulated Depreciation—Office Equipment 5,000 Accounts Payable 9,900...
Use a switch statement to write a function that returns TRUE if a character is a...
Use a switch statement to write a function that returns TRUE if a character is a consonant and returns FALSE otherwise.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT