Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

question: Create a tab using the data provided. Then create a multi - dimentional CUBE in snowflake to produce the following report - 1 .

question:
Create a tab using the data provided. Then create a multi-dimentional CUBE in snowflake to
produce the following report -
1. Total Sale value by -
a. Each Year
b. Each Quarter
c. Each Month
d. Each Product
e. Each Year,Quarter Combination
f. Each Year,Month Combination
g. Each Year,Product Combination
h. Each Quarter,Month Combination
i. Each Quarter,Product Combination
j. Each Month,Product Combination
k. Each Year,Quarter,Month Combination
l. Each Year,Quarter,Product Combination
m. Each Year,Month,Product Combination
n. Each Quarter,Month,Product Combination
o. Total Sales value.
below is the data:
year quarter month product sales_amount
2021 Q1 Jan A 1000
2021 Q1 Jan B 2000
2021 Q1 Jan C 3000
2021 Q1 Feb A 1500
2021 Q1 Feb B 2500
2021 Q1 Feb C 3500
2021 Q1 Mar A 2000
2021 Q1 Mar B 3000
2021 Q1 Mar C 4000
2021 Q2 Apr A 1200
2021 Q2 Apr B 2200
2021 Q2 Apr C 3200
2021 Q2 May A 1800
2021 Q2 May B 2800
2021 Q2 May C 3800
2021 Q2 Jun A 2200
2021 Q2 Jun B 3200
2021 Q2 Jun C 4200
SNOWFLAKE CONNECTION INSTRUCTIONS
pip3 install --upgrade snowflake-connector-python
Login to snowflake, create a database ('test' in this script and a schema 'sales' in this script)
CODE TO CONNECT TO SNOWFLAKE from python
#!/usr/bin/env python
import snowflake.connector
# Gets the version
ctx = snowflake.connector.connect(
user='YOUR USER ID',
password='YOUR PASSWORD',
account='ACCOUNT NAME'
)
cs = ctx.cursor()
try:
cs.execute("USE DATABASE TEST")
cs.execute("USE SCHEMA SALES")
cs.execute(
"CREATE OR REPLACE TABLE "
"test_table(col1 integer, col2 string)")
cs.execute("CREATE TABLE sales_data ( year INT, quarter VARCHAR(2), month VARCHAR(3), product VARCHAR(10),
sales_amount DECIMAL(10,2))")
cs.execute("SELECT current_version()")
one_row = cs.fetchone()
print(one_row[0])
finally:
cs.close()
ctx.close()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago