How To Save Files: Menu On The Top Left and Save As Yourname - Sql. As Shown Below
How To Save Files: Menu On The Top Left and Save As Yourname - Sql. As Shown Below
How To Save Files: Menu On The Top Left and Save As Yourname - Sql. As Shown Below
MySQL( .SQL): After executing all the commands/answers, click on the file
menu on the top left and save as Yourname.sql.
As shown below:
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 1
Order Management Schema Details
PART 1
This document captures the scenario of simple order management functionality of an online retail
store.
Typical purchase scenario: A customer places an order for N products specifying quantity for each
line item of the order. Every product belongs to a product class (or category). All products ordered
in one order, are shipped to customer’s address (in India or outside) by a shipper in one shipment.
Order can be paid using either Cash, Credit Card or Net Banking.
There can be customers who may not have placed any order. Few customers would have cancelled
their orders (As a whole order, no cancellation of individual item allowed). Few orders may be ‘In
process’ status. There can also be products that were never purchased.
Shippers use optimum sized cartons (boxes) to ship an order, based on the total volume of all
products and their quantities. Dimensions of each product (L, W, H) is also stored in the database. To
keep it simple, all products of an order are put in one single appropriately sized carton for shipping.
You are hired by a chain of online retail stores “Reliant retail limited”. They provided you with
“orders” database and seek answers to the following queries as the results from these queries will
help the company in making data driven decisions that will impact the overall growth of the online
retail store.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 2
ER Diagram
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 3
1. Write a query to display carton id, (len*width*height) as carton_vol and identify the
optimum carton (carton with the least volume whose volume is greater than the total
volume of all items (len * width * height * product_quantity)) for a given order whose order
id is 10006, Assume all items of an order are packed into one single carton (box). (1 ROW)
[NOTE: CARTON TABLE] (6 marks)
order. (6 marks)
3. Write a query to display the order_id, customer id and cutomer full name of customers
along with (product_quantity) as total quantity of products shipped for order ids > 10060. (6
ROWS) (6 marks)
of products have been shipped highest(Quantity) to countries outside India other than USA?
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 4
PART 2:
You are hired by a chain of online retail stores “Fastkart”. They have provided you with
“Fastkart” database and seek answers to the following queries as the results from these
queries will help the company in making data driven decisions that will impact the overall
growth of the online retail stores.
ER Diagram
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 5
5. Write a query to display ProductId, ProductName, CategoryName, Old_Price(price) and
Hint: Use case statement, there should be no permanent change done in table/DB.
6. Display the percentage of females present among all Users. (Round up to 2 decimal places) Add “%”
(1 Row) [Note:
users]
7. Display the average balance for both card types for those records only where CVVNumber > 333
and NameOnCard ends with the alphabet “e”.
8. 8. What is the 2nd most valuable item available which does not belong to the “Motor” category.
(1 Row) (7 marks)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 6