ut-effectiveness / utDataStoR

https://ut-effectiveness.github.io/utDataStoR/
Other
0 stars 0 forks source link

Add graduation.sql to utDataStoR #14

Open andreabr-dixie opened 3 weeks ago

andreabr-dixie commented 3 weeks ago

Need to add a standard graduation.sql to utDataStor. Here is a start of one. This comes from the campus narrative, but we should add Graduation it to utMetrics and have them match.

SELECT a.student_id, a.sis_system_id, b.is_athlete, b.is_veteran, a.cohort_start_term_id, a.cohort_code, a.cohort_code_desc, CASE WHEN b.is_athlete THEN 'BA' -- if athlete, change degree level to BA ELSE a.cohort_degree_level_code END AS cohort_degree_level_code, CASE WHEN b.is_athlete THEN 'Bachelor' -- if athlete, change degree level to Bachelor ELSE a.cohort_degree_level_desc END AS cohort_degree_level_desc, a.cohort_desc, a.full_time_part_time_code, c.is_graduated, a.is_exclusion, b.gender_code, b.death_date, b.ipeds_race_ethnicity, d.ipeds_award_level_code, c.graduated_term_id, c.degree_id, c.graduation_date, c.primary_program_id AS grad_program_id, d.college_desc AS grad_college_desc, d.college_abbrv AS grad_college_abbrv, e.term_start_date, CASE WHEN c.graduation_date - e.term_start_date < 0 THEN NULL ELSE c.graduation_date - e.term_start_date END AS days_to_graduate, f.primary_program_id AS entering_program_id, g.college_desc AS entering_college_desc, g.college_abbrv AS entering_college_abbrv

        FROM export.student_term_cohort a
   LEFT JOIN export.student b ON b.student_id = a.student_id
   LEFT JOIN export.degrees_awarded c
          ON c.student_id = a.student_id
         AND c.is_highest_undergraduate_degree_awarded
         AND c.degree_status_code = 'AW'
   LEFT JOIN export.academic_programs d
          ON d.program_id = c.primary_program_id
   LEFT JOIN export.term e
          ON e.term_id = a.cohort_start_term_id
   LEFT JOIN export.student_term_level_version f
          ON f.student_id = a.student_id AND f.term_id = a.cohort_start_term_id
         AND version_desc = 'Current' -- there seems to have missing data in version
   LEFT JOIN export.academic_programs g
          ON g.program_id = f.primary_program_id