diff --git a/transform/models/L2_core/martyg_avg_by_grade.sql b/transform/models/L2_core/martyg_avg_by_grade.sql new file mode 100644 index 0000000..9a61c51 --- /dev/null +++ b/transform/models/L2_core/martyg_avg_by_grade.sql @@ -0,0 +1,20 @@ +with raw_source as ( + + select * from {{ ref('stg_martyg_personal_loans') }} + +), + +final as ( + + select + grade, + avg(loan_amnt) as avg_loan_amount, + count(*) as total_loans + from raw_source + where loan_status = 'Fully Paid' + group by grade + order by grade + +) + +select * from final diff --git a/transform/models/L2_core/martyg_avg_by_grade.yml b/transform/models/L2_core/martyg_avg_by_grade.yml new file mode 100644 index 0000000..617c02d --- /dev/null +++ b/transform/models/L2_core/martyg_avg_by_grade.yml @@ -0,0 +1,9 @@ +version: 2 + +models: + - name: martyg_avg_by_grade + description: 'Martys model calculating average by grade' + columns: + - name: grade + - name: avg_loan_amount + - name: total_loans