-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2384 from TEAMSchools/psatnmsqt
Psatnmsqt
- Loading branch information
Showing
3 changed files
with
78 additions
and
30 deletions.
There are no files selected for viewing
13 changes: 12 additions & 1 deletion
13
src/dbt/kipptaf/models/collegeboard/psat/intermediate/int_collegeboard__psat.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/dbt/kipptaf/models/collegeboard/psat/intermediate/int_collegeboard__psat_unpivot.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
with | ||
psat as ( | ||
select | ||
cb_id, | ||
powerschool_student_number as local_student_id, | ||
|
||
score, | ||
|
||
concat( | ||
test_name, '_', regexp_extract(score_type, r'^[^_]+_(.+)') | ||
) as score_type, | ||
|
||
safe_cast(latest_psat_date as date) as `date`, | ||
|
||
case | ||
test_type | ||
when 'PSATNM' | ||
then 'PSAT NMSQT' | ||
when 'PSAT89' | ||
then 'PSAT 8/9' | ||
when 'PSAT10' | ||
then 'PSAT10' | ||
end as test_type, | ||
|
||
case | ||
score_type | ||
when 'latest_psat_total' | ||
then 'Composite' | ||
when 'latest_psat_math_section' | ||
then 'Math' | ||
when 'latest_psat_ebrw' | ||
then 'EBRW' | ||
end as test_subject, | ||
|
||
from | ||
{{ ref("int_collegeboard__psat") }} unpivot ( | ||
score for score_type | ||
in (latest_psat_total, latest_psat_math_section, latest_psat_ebrw) | ||
) | ||
) | ||
|
||
select | ||
cb_id, | ||
local_student_id, | ||
`date`, | ||
score_type, | ||
score, | ||
test_type, | ||
test_subject, | ||
|
||
row_number() over ( | ||
partition by local_student_id, test_type, score_type order by score desc | ||
) as rn_highest, | ||
from psat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters