The following are my solutions to the Case Study 7 Balanced Tree questions in
Danny Ma's Serious SQL course
There are 4 data tables available to us in balanced_tree
schema which we can use to run our SQL queries with:
-
Product Details
-
Product Sales
-
Product Hierarcy
-
Product Price
import pandas as pd
import numpy as np
import pyodbc as py
import numpy as np
import warnings
warnings.filterwarnings('ignore')
conn = py.connect(
"DRIVER={SQL Server};SERVER=SHAILESH-PC\SQLEXPRESS;DATABASE=DannyMa;"
)
df_sales = pd.read_sql_query('select * from balanced_tree.sales',conn)
df_pp = pd.read_sql_query('select * from balanced_tree.product_prices',conn)
df_ph = pd.read_sql_query('select * from balanced_tree.product_hierarchy',conn)
df_pd = pd.read_sql_query('select * from balanced_tree.product_details',conn)
conn.close()