Data analysis accesssql_modeloff

21
Using Access SQL to solve ModelOff Data Analysis problem Image credit: ModelOff http://www.modeloff.com/ SELECT [Sales Person], Count(*) FROM (SELECT DISTINCT [Invoice Number], [Sales Person] FROM tblModelOff2013 WHERE Format(Date,"mmmm") = "May") GROUP BY [Sales Person] ORDER BY Count(*) DESC;

description

Our Solution to ModelOff Data Analysis Problem, using Access SQL.

Transcript of Data analysis accesssql_modeloff

Page 1: Data analysis accesssql_modeloff

Using Access SQL to solve ModelOff Data

Analysis problem

Image credit: ModelOff http://www.modeloff.com/

SELECT [Sales Person], Count(*)

FROM

(SELECT DISTINCT [Invoice Number], [Sales Person]

FROM tblModelOff2013

WHERE Format(Date,"mmmm") = "May")

GROUP BY [Sales Person]

ORDER BY Count(*) DESC;

Page 2: Data analysis accesssql_modeloff

What is ModelOff ?ModelOff is a fun, innovative and challenging annual competition for students and

professionals to develop and test their financial modeling skills against friends, colleagues and

top modelers around the world. Competitors undertake two Online Qualification

Rounds before the World’s Top 16 progress to a Live Finals Event held in New York.

http://www.modeloff.com/faq

What is SQL?SQL is a computer language for working with sets of facts and the relationships between them.

Relational database programs, such as Microsoft Office Access, use SQL to work with data.

Unlike many computer languages, SQL is not difficult to read and understand, even for a

novice.

https://support.office.com/en-sg/article/Access-SQL-basic-concepts-vocabulary-

and-syntax-444d0303-cde1-424e-9a74-e8dc3e460671

SQL

Page 3: Data analysis accesssql_modeloff

Data Analysis

Question Appeared in: ModelOff 2013 Round 2

Time Allocated: 20 minutes

Introduction

You are working as a business analyst at a leading hardware retailer. You have been asked to

assist with the analysis of some recent sales data from one of your hardware stores.

Data Structure

The data covers the first 6 months of the year 2013 and has a line for each different item type

sold on each invoice. One or more lines may be associated with a single invoice.

Note that each line also has a quantity field that represents the quantity of that particular item

type sold on that invoice.

Each invoice is associated with one Manager on Duty and one Sales Assistant.

http://www.modeloff.com/wp-content/uploads/2014/08/MO13-Data-Analysis-

Questions-and-Answers.pdf

Image credit: ModelOff http://www.modeloff.com/wp-content/uploads/2014/08/Data-241x179.jpg

Page 4: Data analysis accesssql_modeloff

Presented by:

This solution was not officially endorsed, nor

recommended by ModelOff, and ModelOff

does not guarantee the accuracy of this content.

Page 5: Data analysis accesssql_modeloff

SELECT SUM (Quantity)

FROM tblModelOff2013

WHERE [Item Code]=10

AND [Manager On Duty]="John Jones";

Answer: BResult: 554

QUESTION 1Over the entire analysis period, what was the quantity of item 10 sold while John

Jones was the Manager on duty? Select the closest answer.

A. 300

B. 600

C. 900

D. 2,000

Page 6: Data analysis accesssql_modeloff

SELECT TOP 3 [Item Code]

FROM tblModelOff2013

GROUP BY [Item Code]

ORDER BY SUM(Quantity) DESC;

Answer: A

QUESTION 2Over the entire analysis period, what were the 3 highest selling items by

quantity.

A. 8, 17, 40

B. 4, 11 , 49

C. 6, 17, 18

D. 7, 11, 33

Page 7: Data analysis accesssql_modeloff

SELECT TOP 1 [Sales Person], [Item Code]

FROM tblModelOff2013

GROUP BY [Sales Person], [Item Code]

ORDER BY SUM(Quantity) DESC;

QUESTION 3Over the entire analysis period, which sales person sold the highest cumulative quantity of

a single item, and which item was it?

A. Kelly, Item 17

B. Sally, Item 17

C. Kelly, Item 20

D. Sally, Item 20

Answer: AResult: Kelly Clark - 17

Page 8: Data analysis accesssql_modeloff

SELECT SUM ([Sales Price Per Unit]*[Quantity])

FROM tblModelOff2013

WHERE [Sales Person] Like "*Wendel*";

Answer: CResult: 316,759.67

QUESTION 4What was sales person Wendel's total Sales over the analysis period? Select the

closest answer.

A. $ 15,000

B. $ 30, 000

C. $300,000

D. $500,000

Page 9: Data analysis accesssql_modeloff

SELECT COUNT(*)

FROM

(SELECT DISTINCT [Invoice Number]

FROM tblModelOff2013

WHERE [Sales Person] Like "Sally*") ;

Answer: DResult: 650

QUESTION 5How many invoices did sales person Sally create over the analysis period?

A. 723

B. 985

C. 318

D. 650

Page 10: Data analysis accesssql_modeloff

SELECT TOP 1 [Postal Code]

FROM tblModelOff2013

WHERE Format(Date,"mmmm") = "May"

AND [Item Code] = 5

GROUP BY [Postal Code]

ORDER BY SUM(Quantity) DESC;

Answer: CResult: 3,029

QUESTION 6During the month of May, which postal code bought the most of item 5 by quantity?

A. 3011

B. 3014

C. 3029

D. 3032

Page 11: Data analysis accesssql_modeloff

SELECT COUNT(*)

FROM

(SELECT [Postal Code]

FROM tblModelOff2013

GROUP BY MONTHNAME(MONTH([Date])), [Postal Code]

HAVING MONTHNAME(MONTH([Date]))="February"

AND SUM(Quantity)>400

ORDER BY Sum(Quantity) DESC);

Answer: CResult: 5

QUESTION 7During the month of February, how many postal codes bought more than 400

products by quantity?

A. 3

B. 4

C. 5

D. 6

Page 12: Data analysis accesssql_modeloff

SELECT TOP 3 [Item Code]

FROM tblModelOff2013

WHERE [Postal Code]=3020

GROUP BY [Item Code]

ORDER BY SUM([Cost per Unit]*[Quantity]) DESC;

Answer: A

QUESTION 8Over the entire dataset, which 3 items did Postcode 3020 spend the greatest

dollars on?

A. 6, 9, 46

B. 3, 6, 9

C. 7, 20, 28

D. 6, 9, 44

Page 13: Data analysis accesssql_modeloff

SELECT [Sales Person]

FROM

(SELECT DISTINCT [Invoice Number], [Sales Person]

FROM tblModelOff2013

WHERE Format(Date,"mmmm") = "May")

GROUP BY [Sales Person]

ORDER BY Count(*) DESC;

Answer: C

QUESTION 9What is the rank of sales persons from highest to lowest based on the number of invoices

written during the month of May?

A. Kelly, Sally, Amy, Wendel, Benny

B. Kelly, Wendel, Amy, Sally, Benny

C. Kelly, Amy, Wendel, Sally, Benny

D. Kelly, Amy, Sally, Benny, Wendel

Page 14: Data analysis accesssql_modeloff

SELECT TOP 1 [Invoice Number]

FROM tblModelOff2013

WHERE [Sales Person] Like "Wendel*"

GROUP BY [Invoice Number]

ORDER BY Sum([Sales Price Per Unit]*[Quantity]) DESC;

Answer: AResult: 143

QUESTION 10What was the invoice number of the largest invoice by revenue that sales person Wendel

wrote during the analysis period?

A. 143

B. 2166

C. 3269

D. 3327

Page 15: Data analysis accesssql_modeloff

SELECT [Sales Person]

FROM tblModelOff2013

GROUP BY [Sales Person]

ORDER BY SUM([Discount Given]*[Ticket Price Price Per

Unit]*[Quantity]) DESC;

Answer: C

QUESTION 11Over the entire analysis period, what is the rank of sales persons according to the dollar

value of discounts given, from most discounts to least discounts?

A. Kelly, Amy, Wendel, Sally, Benny

B. Kelly, Wendel, Amy, Benny, Sally

C. Amy, Wendel, Kelly, Benny, Sally

D. Amy, Kelly, Wendel, Sally, Benny

Page 16: Data analysis accesssql_modeloff

SELECT TOP 1 MonthName(Month([Date]))

FROM tblModelOff2013

GROUP BY MonthName(Month([Date]))

ORDER BY SUM([Sales Price Per Unit]*[Quantity]) DESC;

Answer: AResult: March

QUESTION 12Which month had the highest revenue?

A. March

B. April

C. May

D. June

Page 17: Data analysis accesssql_modeloff

SELECT TOP 1 [Item Code]

FROM tblModelOff2013

WHERE [Postal Code] In (3013,3017,3031)

GROUP BY [Item Code], MonthName(Month([Date]))

HAVING MonthName(Month([Date]))="February"

ORDER BY Sum(([Sales Price Per Unit]-[Cost Per

Unit])*[Quantity]) DESC;

Answer: CResult: 17

QUESTION 13Only considering postal codes 3013, 3017 and 3031, which item had the highest total

profit during the month of February?

A. 3

B. 6

C. 17

D. 44

Page 18: Data analysis accesssql_modeloff

SELECT MonthName(Month([Date]))

FROM tblModelOff2013

GROUP BY MonthName(Month([Date]))

ORDER BY Sum(([Sales Price Per Unit]-[Cost Per

Unit])*[Quantity]) DESC;

Answer: A

QUESTION 14What is the rank of months from highest to lowest based on profit over the entire

analysis period?

A. March, June, April, May, January, February

B. March, June, May, April, February, January

C. June, April, May, January, February, March

D. March, June, May, January, February, April

Page 19: Data analysis accesssql_modeloff

SELECT TOP 3 MonthName(Month([Date]))

FROM tblModelOff2013

WHERE [Postal Code] Not In (3019,3028)

AND [Item Code] Not In (4,5,6,17,18)

AND [Manager On Duty]="John Jones"

GROUP BY MonthName(Month([Date]))

ORDER BY SUM(([Sales Price Per Unit]-[Cost Per

Unit])*[Quantity]) DESC;

Answer: B

QUESTION 15During which 3 months did manager John Jones have the highest cumulative profit ignoring

all sales to postal codes 3019 and 3028 and ignoring all sales of items 4, 5, 6, 17 and 18?

A. March, May, June

B. February, March, May

C. February, March, June

D. February, May, June

Page 20: Data analysis accesssql_modeloff

SELECT SUM(Quantity) AS Units

FROM tblModelOff2013

WHERE ( [Sales Person] Like "Benny*" Or [Sales Person] Like

"Kelly*")

AND [Item Code]=3

AND MonthName(Month([Date]))="June";

Answer: BResult: 116

QUESTION 16What quantity of item 3 was sold by sales persons Benny and Kelly together during

the month of June?

A. 9

B. 116

C. 134

D. 475