Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Jul 9, 2024
2 parents ea87564 + a779564 commit 4b884e7
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
with
cs_roster as (
select
co.student_number,
co.academic_year,
co.grade_level,
co.school_abbreviation as school_name,

b.behavior_date,
b.behavior,
b.notes,

cast(left(b.behavior, length(b.behavior) - 5) as int) as cs_hours,
from {{ ref("base_powerschool__student_enrollments") }} as co
left join
{{ ref("stg_deanslist__behavior") }} as b
on (
co.student_number = b.student_school_id
and b.behavior_category = 'Community Service'
and (b.behavior_date between co.entrydate and co.exitdate)
)
where
co.grade_level between 9 and 12
and co.is_enrolled_y1
and co.academic_year >= {{ var("current_academic_year") }} - 1
)

select
academic_year,
school_name,
student_number as `StudentID`,
_9 as `HOURS-9TH`,
_10 as `HOURS-10TH`,
_11 as `HOURS-11TH`,
_12 as `HOURS-12TH`,
from
(
select
hs.academic_year,
hs.school_name,
hs.student_number,
hs.grade_level,
hs.cs_hours,
from cs_roster as hs
)
pivot (sum(cs_hours) for grade_level in (9, 10, 11, 12))

0 comments on commit 4b884e7

Please sign in to comment.