Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!