Question: Create a tab using the data provided. Then create a multi - dimentional CUBE in snowflake to produce the following report - 1 . Total
Create a tab using the data provided. Then create a multidimentional CUBE in snowflake to
produce the following report
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 dataset:
year quarter month product salesamount
Q Jan A
Q Jan B
Q Jan C
Q Feb A
Q Feb B
Q Feb C
Q Mar A
Q Mar B
Q Mar C
Q Apr A
Q Apr B
Q Apr C
Q May A
Q May B
Q May C
Q Jun A
Q Jun B
Q Jun C
SNOWFLAKE CONNECTION INSTRUCTIONS
pip install upgrade snowflakeconnectorpython
Login to snowflake, create a database test in this script and a schema 'sales' in this script
CODE TO CONNECT TO SNOWFLAKE from python
#usrbinenv python
import snowflake.connector
# Gets the version
ctx snowflake.connector.connect
user'YOUR USER ID
password'YOUR PASSWORD',
account'ACCOUNT NAME'
cs ctxcursor
try:
csexecuteUSE DATABASE TEST"
csexecuteUSE SCHEMA SALES"
csexecute
"CREATE OR REPLACE TABLE
"testtablecol integer, col string
csexecuteCREATE TABLE salesdata year INT, quarter VARCHAR month VARCHAR product VARCHAR
salesamount DECIMAL
csexecuteSELECT currentversion
onerow csfetchone
printonerow
finally:
csclose
ctxclose
A Get the following result using ROLLUP operation on the data cube created as in above questions.
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
B Use DRILL DOWN on Quarter to create the CUBE on dimention year month, product, salse
amount and perform the following operation
a Each Year
b Each Month
c Each Product
d Each Year,Month Combination
e Each Year,Product Combination
f Each Month,Product Combination
g Each Year,Month,Product Combination
C Create a dice from cube created in last assignment on product A & C month having ODD
number and Quarter having EVEN number and execute the following opertions
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
