Answered step by step
Verified Expert Solution
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 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 data:
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started