Manthan SQL Test - Tables & Questions
Manthan SQL Test - Tables & Questions
Customer EM_CONTACTABLE
Customer SMS_CONTACTABLE
Customer DM_CONTACTABLE
Purchase PRCH_TYP_CD
Purchase PRCH_DT
Purchase PRCH_TOT_AMT
Purchase PRCH_TAX_AMT
Purchase ESTIMATED_SHIPPING_COST
Purchase ESTIMATED_HANDLING_COST
Purchase_Lines PRCH_ID Primary
Purchase_Lines ACTUAL_PRICE_AMT
Purchase_Lines PRCH_CNT
Purchase_Lines RETURN_REASON_CD
Purchase_Lines CANCEL_FLG
Purchase_Lines STORE_LANDED_COST
Purchase_Discou
PRCH_ID Primary
nt
Purchase_Discou
PRCH_ITEM_ORD Primary
nt
Purchase_Discou
DISC_KEY Primary
nt
Purchase_Discou
INDIV_ID Foreign
nt
Purchase_Discou
DISC_TYP_CD
nt
Purchase_Discou
DISC_AMT
nt
Purchase_Discou
COUPON_CD
nt
Contact CONTACT_POINT_TYP_CD
Contact CELL_KEY
Contact OUTPUT_DT
Contact MAILED_DT
Contact OPENED_DT
Contact PROGRAMNAME
Contact DELIVERED_FLG
Contact CLICK_CNT
Contact CAMPAIGNCODE
Contact FST_CLICK_DT
Contact LST_CLICK_DT
Store STORE_ID Primary
Store STORE_TYP_CD
Store STORE_NUMBER
Store STATE_CODE
Store COUNTRY_CODE
Store STORE_TYPE_DESCRIPTION
Description
Unique identifier for the customer.
(Note:
Legacy customer_ids are less than 200,000,000,000 .
Customer IDs generated from real time environment range from 200,000,000,000 through 499,99,999,999
Customer IDs generated from the ELMR database begin at 500,000,000,000)
INDIV_ID represents a surrogate key assigned by Recognition Manager and has a 1 to N relationship with
HH_ID
For Payless, the INDIV_ID in the MDM is populated with the EMAIL or TELECOM_ID for Email or
Phone only Customers.
Identifier for the email address that is associated with the individual in the ODS.
Identifier for the phone that is associated with the individual in the ODS.
Identifier for the mobile phone that is associated with the individual in the ODS.
An indicator which specifies if the customer qualifies for email
Valid Values
Y,N
RECEIVE_EMAIL=1 and EMAIL_ID is not null and email is valid and deliverable then Y else N
An indicator which specifies if the customer qualifies for SMS
o RECEIVE_SMS=1 and Mobile number is not null and mobile number is valid then Y else N
Individual ID
Customer_ID of the individual
Customer House Address
Email_ID of the individual determined by ODS selection logic.
The best gender for an individual . Default uses Inferred Gender from Infobase as best gender.
Primary key for transaction (surrogate key)
Individual id. This is only populated when the individual making the transaction is known.
Code that identifies whether the purchase was made in a brick and mortar store (STR) or through an online
order (ORD).
Valid values:
STR- Purchase made in store
ORD - Purchase made on-line
Date the Purchase occured
Actual total amount paid on that purchase. This is the discounted price and includes tax.
For Point of Sale (POS) this is sourced from POS Transaction Header, Total Transaction Amount .
For ECOM, the is sourced from ECOM Transaction Header. Total Transaction Amount of the demand
record.
Tax Amount for the Purchase. Dervived by Additon of state and local sales tax amounts.
For Point of Sale (POS) this is sourced from POS Transaction Header, Transaction State Sales Tax +
Transaction Local Sales Tax .
For ECOM, the is sourced from ECOM Transaction Header. Transaction State Sales Tax + Transaction
Local Sales Tax of the demand record
Unique identifier for a store location. Surrogate key for Store Number
Shipping amount for the ECOM order.
Sourced from ECOM Transaction Header file SHIP OR HANDLING CHARGE AMT, for demand orders.
Estimated cost to ship a product to a customer or to a store. Currently only populated for Ecommerce
transactions. Will be 0 for all POS transactions.
Estimated cost of how much it costs Payless to "handle" the product in it's DC's when shipping the product.
Will be 0 for all POS transactions.
Primary key for transaction (surrogate key)
The order (number) of line items in the purchase.
For POS transactions, this is derived from the source transaction sequence number.
For ECOM transactions this is derived as row number over purchase key and data source code ordered by
Lot Number, Size Code, and Lot Number Sequence..
Individual id. This is only populated when the individual making the transaction is known.
Actual price of item before any discounts or tax
Sourced from:
Sourced from:
ECOM - If cancel_flg=Y, value=0, else 1. Records have been un-rolled to 1 record per item in transaction
Unique key to identify a product at a point in time.
Code that indicates the type of the return. This field is sourced from Transaction Line Item in the
transaction detail file
RA - Return Accessory
RS - Shoe
Flag set to Cancel/Void the line item from the purchase. (valid Values: Y/N)
Cost of moving a lot to a store so it can be sold.
If Store Landed Cost doesn't come over with data then the this will be populated with Estimated Store
Landed Cost and the Estimated Store Landed Cost Percent field will be populated .
Primary key for transaction (surrogate key)
For POS transactions, this is derived from the source transaction sequence number.
For ECOM transactions this is the PRCH_ITEM_ORD from the detail record
(MDM_PURCHASE_ITEM), if there is a matching lot and size code, else this is populated with 0.
For POS transactions, this is the coupon discount code from the store discount file (if populated), else
discount source number.
For ECOM transactions, this is the promo id concatenated with the discount id from the order discount file
(separated by a dash, i.e. promo_id - discount id)
Sourced from:
POS Transaction Discount file-presence of COUPON DISCOUNT CODE, else DISCOUNT SOURCE
NUMBER (ex: 00000000000025146781)
ECOM Transaction Discount file -PROMO ID '-' DISCOUNT ID (ex: 2015-02-US-BIRTHDAY-c-pro-
4234002)
Sourced from:
POS Transaction Discount file-TRANSACTION TYPE
ECOM Transaction Discount file -DISCOUNT TYPE
Discount Amount
For POS this is sourced from coupon discount amount on the store trans discount file.
For ECOM, this is sourced from the discount amount on the ecom trans discount file. The total discount
amount is divided by the number of items fulfilled with same lot and size.
Sourced from:
POS Transaction Discount file-COUPON DISCOUNT CODE (ex:251441075)
ECOM Transaction Discount file -COUPON ID (ex: 251441075)
Primary key for products (surrogate key) tied to the natural key of product key, ek_data_source_cde,
prdct_type_cd and start_dt.
Shoe width description.
Category description
Sub-category description
Department description
Class code description
Sub class description
Branded product description, i.e. Comfort Plus
A unique reference number, from an Oracle sequence, applied to each contact and never repeated.
"Who" is being contacted -- ID that uniquely identifies the individual.
"How" the individual is being contacted--channel. Determines the type of id populating contact_point_id
Valid Values:
A=ADDRESS_ID
E= EMAIL_ID
P=TELECOM_ID
S=SMS/Text
H=HISTORICAL PROMOTIONS
"Where" the individual is being contacted. Specifically, the ID of the point at which the individual was
contacted: email_id, telecom_id, name_addr_id, etc?
Valid Values:
NAME_ADDR_ID, EMAIL_ID or TELECOM_ID
CELL_KEY from Unica (example: A000007710)
Will contain Campaign_ID for Legacy campagns (Campaigns pre-ELMR)
"When" this contact was output
"When" the contact was mailed for delivery
Date the contact resulted in an "opened" resolution.
Program of which the campaign is associated (ex:Birthday-2012)
Indicates whether delivered successfully.
Y=Delivered
N=Not delivered
Number of times a click occurred in this email message.
Unique identifier for a campaign, formatted as C######### (ex: C000005289)
Date/Time of first click on this email, calculated from EMAIL_CLICK.
Most recent click, calculated from EMAIL_CLICK.
Unique identifier for a store location. Location identifier (Links to Store List ID); Store Number surrogate
key
Indicates the type of store.
CB - Central Business
FS - Free Standing
JC - Junior Center
LD or Null – Unknown
M – Mall
SC - Shopping Center
Purchase_Discount
Product
Purchase
Purchase_Lines
Store
Customer
Individual
CONTACT_HISTORY
ITEM_DISCOUNT
PRODUCT
PURCHASE
PURCHASE_ITEM
STORE
CUSTOMER
INDIVIDUAL
CUSTOMER_I TELECOM_ID_P TELECOM_ID_M
INDIV_ID EMAIL_ID
D HONE OBILE
35230007 64373776 1200057636220 1300130771830 NA
133430054 36224059 1200057636226 1300148459119 NA
116448349 1929518 1200057636230 1300089122579 NA
24752895 94061473 1200057636233 1300147574261 NA
132845611 49881471 1200057636244 1300148744993 NA
131996728 94000804 1200057636255 1300076804657 NA
130228412 25298983 1200057636256 1300148547846 NA
132551001 68226384 1200057636277 1300148086805 NA
19122011 23386429 1200057636278 1300148614077 1300148614077
45377925 45635699 1200057636281 1300132759723 1300080072786
EM_CONT SMS_CONT DM_CONT
ACTABLE ACTABLE ACTABLE
Y N Y
N N Y
N N Y
Y N Y
Y N N
Y N N
N N N
Y N Y
N N Y
Y N Y
CUSTOMER_I NAME_ADDR_I BST_GENDER_C
INDIV_ID EMAIL_ID
D D D
110968151 104610263 1400320129059 1200154651092 F
104531461 500189262185 1400223529628 1200025889136 U
41806834 11971891 1400052337264 NA F
18559220 83172450 1400121648299 NA U
67540209 6222741 1400049679939 NA U
1200044377947 94798367 1400122839588 1200044377947 NA
14931274 32409610 1400075263820 NA U
110008313 200014493344 1400304268119 NA M
34556707 75237206 1400115660090 1200040043680 U
108522029 200011724073 1400289570990 1200126247492 F
PRCH_T PRCH_TOT PRCH_TAX
PRCH_ID INDIV_ID PRCH_DT STORE_ID
YP_CD _AMT _AMT
2400762951448 110968151 STR 11/3/2014 22.39 0 2300000011466
2400666080358 104531461 STR 5/21/2014 -16.95 -0.96 2300000010661
2400645868128 41806834 STR 5/5/2015 -20.79 -0.8 2300000011130
2400361535418 25298983 STR 1/22/2016 63.85 3.89 2300000010649
2400692685425 68226384 STR 12/14/2013 19.06 1.08 2300000009071
2400214747421 68088307 STR 9/26/2012 0 0 2300000009764
2400090145368 84275674 STR 8/31/2013 27 0 2300000013086
2400794856693 92052194 STR 6/26/2015 8.45 0.97 2300000008986
2400715040860 62720674 STR 8/23/2012 -15.74 -0.75 2300000008368
2400890047278 102157908 STR 5/9/2016 43.45 4.48 2300000014865
ESTIMATED_H
ORDER_SHI ESTIMATED_SH
ANDLING_COS
PPING_AMT IPPING_COST
T
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
NA 0 0
ACTUA RETUR
PRCH_IT PRCH_C
PRCH_ID INDIV_ID L_PRICE PRDCT_PT_ID N_REAS
EM_ORD NT
_AMT ON_CD
2400762951448 1 110968151 12.99 1 3507326239001 NA
2400762951448 2 110968151 -24.99 1 3512474389001 RS
2400762951448 4 110968151 12 1 3507352349001 NA
2400666080358 1 104531461 39.99 1 3507437089001 NA
2400666080358 2 104531461 -27.99 1 3507166739001 RS
2400666080358 3 104531461 19.99 1 3512582659001 NA
2400645868128 1 41806834 8 1 3506978259001 NA
2400645868128 2 41806834 15 1 3507571789001 NA
2400361535418 1 25298983 -6.99 -1 3507115939001 NA
2400692685425 1 68226384 -15.99 1 3511915889001 RS
STORE_L
CANCEL
ANDED_
_FLG
COST
N 2.61
N 6.99
N 7.19
N 10.51
N 6.98
N 8.29
N 3.8
N 6.48
Y 1.94
N 5.86
PRCH_ID PRCH_ITEM_ORD DISC_KEY INDIV_ID DISC_TYP_CD DISC_AMT
2400762951448 3 251415812 4993165 CP -3
2400762951448 5 1000 4993165 $D -5
2400666080358 4 1000 68330601 $D -5
2400666080358 5 1000 99929314 $D -20
2400188124091 6 1000 53838455 ID -5
2400188124091 2 1000 53838455 ID -1.5
2400188153627 6 1000 29571126 ID -5
2400188153627 4 1000 29571126 ID -6.5
2400188164960 3 1000 30633694 $D -1
2400188164960 4 1000 30633694 ID -1
COUPON_CD
251415812
NA
NA
NA
NA
NA
NA
NA
NA
NA
PRDCT_PT_ID LOT_WIDTH_DESC CATEGORY_DESC SUB_CATEGORY_DESC
3515870629001 REGULAR WIDTH WOMENS WOMENS ATHLETIC
3516500549001 REGULAR WIDTH ACCESSORIES ACCESSORIES
3509776819001 WIDE WIDTH WOMENS WOMENS W/O ATHLETIC
3509107619001 REGULAR WIDTH WOMENS WOMENS W/O ATHLETIC
3517355549001 REGULAR WIDTH WOMENS WOMENS W/O ATHLETIC
3516034039001 REGULAR WIDTH ACCESSORIES ACCESSORIES
3517287539001 REGULAR WIDTH ACCESSORIES ACCESSORIES
3516039999001 REGULAR WIDTH WOMENS WOMENS W/O ATHLETIC
3510689449001 REGULAR WIDTH MENS MENS
3510339849001 REGULAR WIDTH WOMENS WOMENS W/O ATHLETIC
DEPARTMENT_DESC CLASS_DESC SUB_CLASS_DESC
W ATHLETICS PERFORMANCE ATHLEISURE
ACCESS HAIR EC HAIR
W SANDALS BOXED WIDE WIDTH
W SANDALS MISC MISCELLANEOUS
W CASUALS FLATS JUNIOR
ACCESS SUNGLASSES EC-SUNGLASSES
SOCK-SHCARE WOMENS DRESS/CASUAL
W DRESS FASHION SHOOTIES/OXFORD
M BOOTS DRESS/CASUALS MODERN CLASSIC
W CASUALS TAILORED JUNIOR
BRANDED_DESC
AIRWALK
BRASH JUNIORS ACCESSORIES
FIONI
NOT BRANDED
AMERICAN EAGLE WOMENS
MINICCI
MINICCI
AMERICAN EAGLE WOMENS
STATE STREET
LOWER EAST SIDE
CONTACT_ CONTACT_POI CONTACT_POI
INDIV_ID CELL_KEY OUTPUT_DT
URN NT_TYP_CD NT_ID
4764286270 15466167 E 1200043886184 B000000942 10/6/2015 16:55
4755952314 33089004 E 1200053952745 B000000931 10/2/2015 9:15
4783544295 30133889 E 1200025941530 B000000943 10/7/2015 16:47
4755475877 27942896 E 1200046571279 B000000943 10/7/2015 16:17
4696638133 73365556 E 1200024028412 B000000943 10/7/2015 18:03
4768543673 44067084 E 1200063058759 B000000932 10/3/2015 6:33
4771771144 1145153 E 1200037766911 B000000932 10/3/2015 5:10
4758469082 83905291 E 1200040771571 B000000931 10/2/2015 11:25
4770849093 63676910 E 1200022550229 B000000931 10/2/2015 10:04
4756327489 45791610 E 1200031760389 B000000931 10/2/2015 10:03
FST_CLICK LST_CLICK
MAILED_DT OPENED_DT PROGRAMNAME
CLICK_CNT
_DT _DT
10/6/2015 17:27 NA FY15FP06 0 NA NA
10/2/2015 14:00 NA FY15FP06 0 NA NA
10/7/2015 17:13 NA FY15FP06 0 NA NA
10/7/2015 17:13 NA FY15FP06 0 NA NA
10/8/2015 9:45 10/7/2015 18:45 FY15FP06 0 NA NA
10/3/2015 10:29 NA FY15FP06 0 NA NA
10/3/2015 10:29 NA FY15FP06 0 NA NA
10/2/2015 14:00 NA FY15FP06 0 NA NA
10/2/2015 13:07 NA FY15FP05 0 NA NA
10/2/2015 12:11 NA FY15FP06 0 NA NA
DELIVEREDCAMPAIGNCODE
Y C000005328
Y C000005330
NA C000005330
Y C000005325
Y C000005328
Y C000005323
Y C000005330
Y C000005330
Y C000005306
Y C000005323
STORE_ID STORE_TYP_CD STORE_NUMBER STATE_CODE COUNTRY_CODE
2300000014939 M 6666 FL US
2300000008980 CB 7373 HN HN
2300000009060 SC 6309 PA US
2300000009039 SC 6654 TX US
2300000008754 CB 3129 NY US
2300000011198 M 3956 GA US
2300000010289 NA 7037 CA US
2300000010332 SC 5262 AL US
2300000010724 M 5932 ON CA
2300000010520 SC 6716 FL US
STORE_TYPE_DESCRIPTION
MALL
CENTRAL BUSINESS
SHOPPING CENTER
SHOPPING CENTER
CENTRAL BUSINESS
MALL
NA
SHOPPING CENTER
MALL
SHOPPING CENTER
Write Queries for finding the following:
1 Net Sales and Margin per Individual
2 Net Sales and Margin for online and in-store transactions per day
3 Net Sales and Margin aggregated by communication channel eligibility
4 Net Sales and Margin and discount amount aggregated at coupon level
5 Net Sales and Margin aggregated by customer recency
6 Net Sales and Margin aggregated by Store Type
7 Email, SMS, Direct Mail sent to customers during a Promotion
8 Delivery rate, Open and Click Rate by Campaign Code, Promotion
9 Wide width and Regular units bought at Individual level
10 Category wise units bought at Individual level
Communication
E - Email
Channels = e- CONTACT_PO
S - SMS
mail, SMS, Direct INT_TYP_CD
A - Direct
Mail
urn_reason_cd not in ('RA','RS')) then (-1*STORE_LANDED_COST)
RS') then (-1*STORE_LANDED_COST)
HIPPING_COST-ESTIMATED_HANDLING_COST-VARIABLE_PRODUCT_COST