Skip to content

Commit 4b02598

Browse files
committed
implemented macro and final table
1 parent 0cca02d commit 4b02598

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% macro categorize_risk(credit_score) %}
2+
CASE
3+
WHEN {{ credit_score }} >= 80 THEN 'Low Risk'
4+
WHEN {{ credit_score }} >= 50 THEN 'Medium Risk'
5+
ELSE 'High Risk'
6+
END
7+
{% endmacro %}

german_credit_data/models/intermediate/int_customer_segmentation.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
WITH scored_data AS (
22
SELECT
33
*,
4-
CASE
5-
WHEN credit_score >= 80 THEN 'Low Risk'
6-
WHEN credit_score >= 50 THEN 'Medium Risk'
7-
ELSE 'High Risk'
8-
END AS risk_segment
4+
{{ categorize_risk('credit_score') }} AS risk_segment
95
FROM {{ ref('int_credit_scores') }}
106
)
117

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SELECT
2+
credit_amount,
3+
duration,
4+
age,
5+
gender,
6+
housing,
7+
job_category,
8+
risk_segment,
9+
credit_score,
10+
age_group,
11+
default_risk_percentage
12+
FROM {{ ref('int_default_risk') }}
13+

0 commit comments

Comments
 (0)