Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

README

1. Create a DB in some O-RDBMS (ideally PostgreSQL). Create tables as per the data description below.
2. Download CSV for the 4 tables from the links below. The tables are not necessarily fully normalised and well-structured. (Welcome to the real world!)
3. Import the contents of the 4 CSVs in the 4 tables respectively.
4. Attempt the 25 exercises listed below.
5. Send back only the query used and the row count for our consideration. If you land a face-to-face interview basis your submissions, you’ll be asked to
i. Explain how you went about creating some of the queries
ii. Make on-the-spot amendments

DATA DESCRIPTION
Counties (99 rows)
County (text)
Population (integer)
Products (9977 rows)
Item_no (integer) (primary key)
Category_name (text) (upper)
Item_description (text) (proper)
Vendor (integer)
Vendor_name (text) (proper)
Bottle_size (integer)
Pack (integer)
Inner_pack (integer)
Age (text) (lots of nulls)
Proof (text)
List_date (timestamp without time zone)
Upc (text)
Scc (text)
Bottle_price (money) ($)
Shelf_price (numeric 10,2)
Case_cost (numeric 10,2)
Stores (1973 rows)
Store (integer) (primary key)
Name (text) (proper case)
Store_status (text) (A/I)
Store_address (text) (physical address, long, lat) (proper case)
Address_info (text) (po #, unit#, suite#) (many nulls)
Sales (3,049,913 rows)
Date (timestamp without time zone)
Convenience_store (text)
Store (integer)
County_number (text)
County (text)
Category (text) (number stored as text)
Category_name (text)
Vendor_no (text) (number stored as text)
Vendor (text) (proper case)
Item (integer)
Description (text) (proper case)
Pack (integer)
Liter_size (integer) (appears ml)
State_btl_cost (money) ($)
Btl_price (money) ($)
Bottle_qty (integer)
Total (numeric, 10, 2)

TABLES
CSV files downloadable from this link.
QUESTIONS/EXERCISES
(send back only query & number of of rows. don’t forget the number of rows)
1. Which products have a case cost of more than $100?
2. Which tequilas have a case cost of more than $100?
3. Which tequilas or scotch whiskies have a case cost of more than $100?
4. Which tequilas or scotch whiskies have a case cost between $100 and $120?
5. Which whiskies of any kind cost more than $100?
6. Which whiskies of any kind cost between $100 and $150?
7. Which products except tequilas cost between $100 and $120?
8. Which products are not from vendor ‘Jim Beam Brands’?
9. Which products are over 90 proof?
10. Which products have a case cost of less than $60?
11. Which products are either Single Malt Scotches or Canadian Whiskies (based on category name)?
12. Which products have ‘Whiskies’ in the category name?
13. Which products have a shelf_price between $4 and $10?
14. Which products have a bottle_price between $4 and $10?
15. Which unique products come in packs larger than 12?
16. How many unique products have less than 12 in a pack?
17. Which unique products have a case cost of less than $70?
18. Which unique products come in packs larger than 12 AND have a case_cost of less than $70?
19. How many items in the product offering are being sold?
20. Using bottle_qty to size up item demand, query for the volume of bottles being sold by item description (as multiple item numbers exist for same products
being sold by various vendors), calculate and rank the best selling items.
21. Narrow the focus of your analysis in item #20 above to include only the products with higher proof contents. Limit the focus to products with proof percent
value greater than 80.
22. How many unique store locations have recorded sales?
23. Create a list of all the transactions from the active stores locations in Polk county?
24. Create a list of all the store locations in Polk county, and show the sum total of their recorded sales along with the quantity of transactions?
25. Using Sales as the primary table, create links to Products and Stores tables.
● In the output, list the store number (from sales), category_name (from sales) and two aggregated columns: average bottle_price (from products) and
average total price (from sales).
● Use a compounded WHERE clause to limit the calculations to the sales of Tequila (category_name from Sales) from Active stores in Mason City, Iowa.
● Group and sort the data by the store number.

You might also like