Calculating a shopper total number of orders

Assignment Help PL-SQL Programming
Reference no: EM131385054

Assignment 1: Calculating a Shopper's Total Number of Orders

Another commonly used statistic in reports is the total number of orders a shopper has placed. Follow these steps to create a function named NUM_PURCH_SF that accepts a shopper ID and returns a shopper's total number of orders. Use the function in a SELECT statement to display the number of orders for shopper 23. 1. Develop and run a CREATE FUNCTION statement to create the NUM_PURCH_SF function. The function code needs to tally the number of orders (using an Oracle built-in function) by shopper. Keep in mind that the ORDERPLACED column contains a 1 if an order has been placed. 2. Create a SELECT query by using the NUM_PURCH_SF function on the IDSHOPPER column of the BB_SHOPPER table. Be sure to select only shopper 23.

Assignment 2: Identifying the Weekday for an Order Date

 The day of the week that baskets are created is often analyzed to determine consumer shopping patterns. Create a function named DAY_ORD_SF that accepts an order date and returns the weekday. Use the function in a SELECT statement to display each basket ID and the weekday the order was created. Write a second SELECT statement, using this function to display the total number of orders for each weekday. (Hint: Call the TO_CHAR function to retrieve the weekday from a date.) 1. Develop and run a CREATE FUNCTION statement to create the DAY_ORD_SF function. Use the DTCREATED column of the BB_BASKET table as the date the basket is created. Call the TO_CHAR function with the DAY option to retrieve the weekday for a date value. 2. Create a SELECT statement that lists the basket ID and weekday for every basket. 3. Create a SELECT statement, using a GROUP BY clause to list the total number of baskets per weekday. Based on the results, what's the most popular shopping day?

Assignment 3: Calculating Days Between Ordering and Shipping

An analyst in the quality assurance office reviews the time elapsed between receiving an order and shipping the order. Any orders that haven't been shipped within a day of the order being placed are investigated. Create a function named ORD_SHIP_SF that calculates the number of days between the basket's creation date and the shipping date. The function should return a character string that states OK if the order was shipped within a day or CHECK if it wasn't. If the order hasn't shipped, return the string Not shipped. The IDSTAGE column of the BB_BASKETSTATUS table indicates a shipped item with the value 5, and the DTSTAGE column is the shipping date. The DTORDERED column of the BB_BASKET table is the order date. Review data in the BB_BASKETSTATUS table, and create an anonymous block to test all three outcomes the function should handle.

Assignment 4: Adding Descriptions for Order Status Codes

 When a shopper returns to the Web site to check an order's status, information from the BB_BASKETSTATUS table is displayed. However, only the status code is available in the BB_BASKETSTATUS table, not the status description. Create a function named STATUS_DESC_SF that accepts a stage ID and returns the status description. The descriptions for stage IDs are listed in Table 6-3. Test the function in a SELECT statement that retrieves all rows in the BB_BASKETSTATUS table for basket 4 and displays the stage ID and its description.

Assignment 5: Calculating an Order's Tax Amount

Create a function named TAX_CALC_SF that accepts a basket ID, calculates the tax amount by using the basket subtotal, and returns the correct tax amount for the order. The tax is determined by the shipping state, which is stored in the BB_BASKET table. The BB_TAX table contains the tax rate for states that require taxes on Internet purchases. If the state isn't listed in the tax table or no shipping state is assigned to the basket, a tax amount of zero should be applied to the order. Use the function in a SELECT statement that displays the shipping costs for a basket that has tax applied and a basket with no shipping state.

Assignment 6: Identifying Sale Products

When a product is placed on sale, Brewbean's records the sale's start and end dates in columns of the BB_PRODUCT table. A function is needed to provide sales information when a shopper selects an item. If a product is on sale, the function should return the value ON SALE!. However, if it isn't on sale, the function should return the value Great Deal!. These values are used on the product display page. Create a function named CK_SALE_SF that accepts a date and product ID as arguments, checks whether the date falls within the product's sale period, and returns the corresponding string value. Test the function with the product ID 6 and two dates: 10-JUN-12 and 19-JUN-12. Verify your results by reviewing the product sales information.

Verified Expert

Reference no: EM131385054

Questions Cloud

Why is the debt ratio useful as a business benchmark : What are the advantages and disadvantages of a high debt ratio?- Why is the debt ratio useful as a business benchmark?
Discuss about the post given below : Pick a process that you think you would like to use for your Personal Process Improvement Project and draw a SIPOC diagram of it. You will need this for your final project so construct it in a format that you will be able to easily import it into..
What steps would you take to protect your data personally : Now that you're learning about attacks and how to mitigate them, what recommendations would you have to your leadership at your company if this attack had happened on your watch? What steps would you take to protect your data personally?
Compute the percentages of assets in current assets : Compute the percentages of assets in current assets and fixed assets.- and The percentages of financing from (1) spontaneous financing and (2) internal equity.
Calculating a shopper total number of orders : Calculating a Shopper's Total Number of Orders Another commonly used statistic in reports is the total number of orders a shopper has placed. Follow these steps to create a function named NUM_PURCH_SF that accepts a shopper ID and returns a shopper..
Find out if the owner agrees with your conclusions : Acquire a small firm's financial statements. Review the statements and describe the firm's financial position. Find out if the owner agrees with your conclusions.
How will lynns worst case and best case projections affect : If all of C&G Products' other relationships hold, how will Lynn's worst-case and best-case projections affect the income statement and balance sheet in the first year?
Write an essay on the historic movie hidden figures : Write an essay on the historic movie Hidden Figures (which is currently playing in the movie theaters) explaining the main themes and historical reference in regards to this class. Make sure to critique the documentary in historical context and st..
Discuss the different types of german expansionism : Discuss why the different types of German expansionism in the Wilhelmine period helped force Germany and Europe down the path toward war in 1914.The Wilhelmine period was the era where William II became emperor of Germany. He became emperor becau..

Reviews

inf1385054

2/13/2017 5:10:55 AM

Very good work. Much obliged to you for rolling out the improvements after I ask for update from the expert! Thanks to you for the nature of client administration that you give.

inf1385054

2/13/2017 5:10:08 AM

Here I am attaching a database 20929582_1c6 BBcreate.sql Please find the attached file 20929523_1Chapter06.zip I need table description of status id it is in table 6-3. c6_BBcreate sql file

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd