Assignment 2 - SQL-final
Assignment 2 - SQL-final
C. BUDGETED Numbers:
1. All the budgeted numbers are expected targets for 2012 and 2013.
Identify the top 5 states for the year 2012 that have substantially
higher actual numbers relative to budgeted numbers for profits and
sales.
2. Identify area codes within these 5 states that beat budgeted sales
and profits significantly (You need to define what significant means
here).
D. PRODUCT related:
1. In each market, which products have the greatest increase in
profits?
2. In each market, which product types have greatest increase in
sales?
3. Have all products within the product types shown similar behavior,
or some products within a product type have greatest increase in
sales?
E. MARKETING EXPENSES (LOWEST):
1. Which top 5 states have the lowest market expenses as a
percentage of their sales?
2. Do the above 5 states also have the highest profits as a percentage
of sales?
3. Are there any particular product(s) within these markets with the
least marketing expenses?
F.
G. STRATEGY:
1. You are in a high-level strategy meeting to discuss how to improve
performance. This may involve shutting down stores in losing area
codes and/or expanding in very profitable/high growth area.
Evaluate the data and recommend which stores to close and where?
2. Where should the firm focus on expanding?
CONSTRAINT:
REION can be only East, South, Central, West.
TABLE: PRODUCTS (ProdID is the PK)
CONSTRAINTS:
PRODCAT can only be Technology Furniture or Office Supplies
PRODCONT take on only Jumbo Drum, Medium Box, Jumbo Box, Wrap
Bag, Large Box, Small Box, Small Pack
TABLE: ORDERS (OrderID is the PK)
CONSTRAINT:
CUSTSEG can be only Home Office Corporate, Small Business, Consumer.
TABLE: ORDERDET (OrderID (FK), CustID (FK), ProdID (FK) are
together a PK; All FK are on delete restrict)
CONSTRAINTS
ORDPRIORITY can be Low, Medium, High, Critical, Not Specified
ORDSHIPMODE can be Regular Air, Delivery Truck, Express Air
TASKS:
DO the following and copy into Word document the DDL, DML, results, and
any errors. Like in Part A, please copy and paste the first 10 rows if there are
more than 10 rows in the answer.
QUESTION 1: Create the 5 tables given above. You should define primary
keys, foreign keys, and other CHECK constraints. And, load the data from
Excel spreadsheet.
QUESTION 2: ORDER Cancellations
a) What fraction of the orders was cancelled?
b) What were the sales was from cancelled orders?
c) Who are the top five customers in terms of cancelled orders?
QUESTION 3: CUSTOMER related:
a) Who are the top 10 customers in terms of revenues generated?
b) Are there customers who buy mostly some categories of products
and there is a potential for them to buy other product categories?
QUESTION 4: There are differences in the actual (theoretical) price ((unit
price * number of units*(1-discount) + shipping cost) and the actual sales for
all products. There are some discounts and shipping costs. Yet, there are
discrepancies in the theoretical sales and actual sales.
a) How much more or less are the actual sales value compared to the
theoretical sales value?
b) Are certain managers generally pricing more or less than theoretical
sales? Analyze the differences based on the regions/managers.
QUESTION 5: these are product related questions:
a) Products have numbers within its name. Identify the product names
with digits in their name. (hint: use REGEXP_LIKE)
b) Which are the top 5 selling products during the year 2011?
c) Which are the top 10 products with greatest total profit margin?
(i.e., sales*margin).
d) Identify the worst five products in terms of sales?