Question

In: Computer Science

Please implement this in Oracle sql 2.) Write a SELECT statement that answers this question: What...

Please implement this in Oracle sql

2.) Write a SELECT statement that answers this question: What is the total amount ordered for each product? Return these columns:

The product name from the Products table

The total amount for each product in the Order_Items (Hint: You can calculate the total amount by subtracting the discount amount from the item price and then multiplying it by the quantity)

Use the ROLLUP operator to include a row that gives the grand total.

Solutions

Expert Solution

>>Answer

>>Given

SELECT p_name,

round( SUM ( quantity * i.list_price * (1 - discount) ),/when discount is in percentage use (100-discount)/

FROM Product

INNER JOIN Order ON Orders.productID=Products.productID

GROUP BY ROLLUP(p_name);

Explanation:

The SELECT statement is used to select data from a database. We need to select data from two different tables, therefore, we use JOIN.

A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

Assuming that productID is the related column

The INNER JOIN keyword selects records that have matching values in both tables.

The ROLLUP is an extension of the GROUP BY clause. The ROLLUP option allows you to include extra rows that represent the subtotals, which are commonly referred to as super-aggregate rows, along with the grand total row. By using the ROLLUP option, you can use a single query to generate multiple grouping sets.


Related Solutions

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...
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...
Question 2: Please write 2 different questions and their answers about Confidence Intervals. Question 3: Please...
Question 2: Please write 2 different questions and their answers about Confidence Intervals. Question 3: Please give a brief explanation how you use statistics in your studied field.
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to...
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. Values variable for the block are starting payment due date, monthly payment amount and number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining amount of...
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create...
Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create a login for AdventureWorks employees. An employee login should be composed of the first letter of a person's first name combined with their last name. In addition, the login should be all lower case characters. All the required information is located in Person.Person table. Employees can be identified by "EM" value in the PersonType field. The output should include BusinessEntityID, first name (FirstName), last...
Please select all of the correct answers in this question to test your understanding of Type...
Please select all of the correct answers in this question to test your understanding of Type 4 hypersensitivity. Type 4 hypersensitivity is also referred to as delayed hypersensitivity. The severity of the reaction depends upon whether IgG, IgM, or IgE are involved. Type 4 hypersensitivity is mediated by T-cells and the effector cells that they recruit. Type 4 hypersensitivity is most appropriately treated with antihistamines. Type 4 hypersensitivity may result from mismatched blood transfusions.
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade...
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade based on the value stored in a variable called grade. Use the ACC      grading system described in the course syllabus to create the block and set     the initial value of grade as 95. Use only one print statement and no      logical operators in your code. Assume a grade can exceed 100, but it      can’t be negative. Grade Scale: Grade Scale:...
Write the word or phrase that best completes each statement or answers the question. Assume that...
Write the word or phrase that best completes each statement or answers the question. Assume that a simple random sample has been selected from a normally distributed population and test the given claim. Use either the traditional method or P-value method as indicated. Identify the null and alternative hypotheses, test statistic, critical value(s) or P-value (or range of P-values) as appropriate, and state the final conclusion that addresses the original claim. 1) A large software company gives job applicants a...
Question 3: Please create a statement of cash flow with indirect method- Please provide answers to...
Question 3: Please create a statement of cash flow with indirect method- Please provide answers to each category and a one paragraph analysis of the cash flow using the indirect method. Statement of Cash Flow with Indirect method 2011 2010 Difference Operating Investing Financing ASSETS: Current Assets Cash and equivalents $ 2,291.1 $ 2,133.9 Short-term investments    1,164.2       642.2 Account receivable    2,883.9    2,795.3 Inventory    2,357.0    2,438.4 Prepaid expenses and other assets       765.6       602.3...
SHORT ANSWER. Write the word or phrase that best completes each statement or answers the question....
SHORT ANSWER. Write the word or phrase that best completes each statement or answers the question. SCENARIO 8-3 To become an actuary, it is necessary to pass a series of 10 dogs, including the most important one, an dog in probability and statistics. An insurance company wants to estimate the mean score on this dog for actuarial students who have enrolled in a special study program. They take a sample of 8 actuarial students in this program and determine that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT