0% found this document useful (0 votes)
14 views

Project Instructions

The document discusses the schema for an order management system for an online retail store. It includes entities like customers, products, orders, shipments and payments. It then provides 10 questions as part of a SQL assessment for an online retail company. The questions cover writing queries to retrieve and analyze data from the database related to orders, products, shipments and customers.

Uploaded by

Narendra Ganta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Project Instructions

The document discusses the schema for an order management system for an online retail store. It includes entities like customers, products, orders, shipments and payments. It then provides 10 questions as part of a SQL assessment for an online retail company. The questions cover writing queries to retrieve and analyze data from the database related to orders, products, shipments and customers.

Uploaded by

Narendra Ganta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

How to save files

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:

Order Management Schema Details

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.

Project- (MYSQL)

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 1
All the questions comes under MYSQL and the queries should be executed in MYSQL. (SQL Script
-orders.sql)

All Questions carry 8 marks. Total Marks (8 x 10) = 80

ER Diagram

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 2
1. Write a query to display the product details (product_class_code, product_id, product_desc,
product_price) as per the following criteria and sort them descending order of category:
i) If the category is 2050, increase the price by 2000
ii) If the category is 2051, increase the price by 500
iii) If the category is 2052, increase the price by 600

Hint: Use CASE statement, no permanent change in table required.

(60 rows)[NORE:PRODUCT TABLE]

2. Write a query to display (product_class_desc, product_id,


product_desc, product_quantity_avail ) and Show inventory status of products as below
as per their available quantity:

a. For Electronics and Computer categories, if available quantity is <= 10, show
'Low stock', 11 <= qty <= 30, show 'In stock', >= 31, show 'Enough stock'

b. For Stationery and Clothes categories, if qty <= 20, show 'Low stock', 21 <= qty <=
80, show 'In stock', >=81, show 'Enough stock'

c. Rest of the categories, if qty <= 15 – 'Low Stock', 16 <= qty <= 50 – 'In Stock', >=
51 – 'Enough stock'

For all categories, if available quantity is 0, show 'Out of

stock'.

Hint: Use case statement. (60 ROWS)[NOTE : TABLES TO BE USED – product,


product_class]

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 3
3. Write a query to Show the count of cities in all countries other than USA & MALAYSIA, with
more than 1 city, in the descending order of CITIES.
(2 rows)[NOTE :ADDRESS TABLE]

4. Write a query to display the customer_id,customer full name ,city,pincode,and order

details (order id, product class desc, product desc, subtotal(product_quantity *

product_price)) for orders shipped to cities whose pin codes do not have any 0s in them.

Sort the output on customer name, order date and subtotal.(52 ROWS)

[NOTE : TABLE TO BE USED - online_customer, address, order_header,


order_items, product, product_class]

5. Write a Query to display product id,product description,totalquantity(sum(product quantity) for a


given item whose product id is 201 and which item has been bought along with it maximum no. of
times. Display only one record which has the maximum value for total quantity in this scenario.

(USE SUB-QUERY)(1 ROW)[NOTE : ORDER_ITEMS TABLE,PRODUCT TABLE]

6. Write a query to display the customer_id,customer name, email and order details
(order id, product desc,product qty, subtotal(product_quantity * product_price)) for all
customers even if they have not ordered any item.(225 ROWS)
[NOTE : TABLE TO BE USED - online_customer, order_header, order_items,
product]

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 4
7. 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]

8. Write a query to display details (customer id,customer fullname,order id,product quantity)


of customers who bought more than ten (i.e. total order qty) products with credit card or net
banking as the mode of payment per shipped order. (6 ROWS)

[NOTE: TABLES TO BE USED - online_customer, order_header, order_items,]

9.Write a query to display the order_id,customer_id and customer fullname starting with “A” along
with (product quantity) as total quantity of products shipped for order ids > 10030

(5 Rows) [NOTE: TABLES to be used-online_customer,Order_header, order_items]

10. Write a query to display product class description, totalquantity(sum(product_quantity), Total


value (product_quantity * product price) and show which class of products have been shipped
highest(Quantity) to countries outside India other than USA? Also show the total value of those
items.

(1 ROWS)[NOTE:PRODUCT TABLE,ADDRESS TABLE,ONLINE_CUSTOMER


TABLE,ORDER_HEADER TABLE,ORDER_ITEMS TABLE,PRODUCT_CLASS TABLE]

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited 5

You might also like