-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGold Layer Queries.py
More file actions
36 lines (34 loc) · 1.12 KB
/
Copy pathGold Layer Queries.py
File metadata and controls
36 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Databricks notebook source
# MAGIC %sql
# MAGIC --Total Charge Amount per provider by department
# MAGIC select
# MAGIC concat(p.firstname, ' ', p.LastName) Provider_Name,
# MAGIC dd.Name Dept_Name,
# MAGIC sum(ft.Amount)
# MAGIC from
# MAGIC gold.fact_transactions ft
# MAGIC left join gold.dim_provider p on p.ProviderID = ft.FK_ProviderID
# MAGIC left join gold.dim_department dd on dd.Dept_Id = p.DeptID
# MAGIC group by
# MAGIC all;
# COMMAND ----------
# MAGIC %sql
# MAGIC --Total Charge Amount per provider by department for each month for year 2024
# MAGIC select
# MAGIC concat(p.firstname, ' ', p.LastName) Provider_Name,
# MAGIC dd.Name Dept_Name,
# MAGIC date_format(servicedate, 'yyyyMM') YYYYMM,
# MAGIC sum(ft.Amount) Total_Charge_Amt,
# MAGIC sum(ft.paidamount) Total_Paid_Amt
# MAGIC from
# MAGIC gold.fact_transactions ft
# MAGIC left join gold.dim_provider p on p.ProviderID = ft.FK_ProviderID
# MAGIC left join gold.dim_department dd on dd.Dept_Id = p.DeptID
# MAGIC where
# MAGIC year(ft.ServiceDate) = 2024
# MAGIC group by
# MAGIC all
# MAGIC order by
# MAGIC 1,
# MAGIC 3
# MAGIC