This query returns the latest persistence (continuation) score for each student and career (academic level), and calculates the one day and one week shift in this score so that the customer can identify students whose score has changed recently. This query can be adapted to calculate score shifts other than one day or week.
The query also displays the Civitas defined bucket for the student's latest persistence score using the default ranges for these buckets:
Very Low, Low, Moderate, High, Very High
-- Find the latest persistence score for each student and career.
WITH latest_continuation_score AS(
SELECT
fcs.dim_person_id
, fcs.civ_career
, fcs.civ_term_id
, fcs.event_ts
, fcs.prediction
FROM data_mart.fact_continuation_scores fcs
WHERE
-- This step ensures that the query returns the latest score for each student.
fcs.event_ts =(SELECTMAX(fcs1.event_ts)
FROM data_mart.fact_continuation_scores fcs1
WHERE fcs.dim_person_id = fcs1.dim_person_id
AND fcs.civ_career = fcs1.civ_career
AND fcs.civ_term_id = fcs1.civ_term_id)
-- This step ensures that the query returns scores for currently enrolled students only.
-- Only currently enrolled students will have a score on the latest day.
AND fcs.event_ts =(SELECTMAX(fcs2.event_ts)
FROM data_mart.fact_continuation_scores fcs2)
)
, continuation_score_shift AS(
-- Change the '7 days' or '1 day' thresholds below to use a different window for the score shift.
SELECT
lcs.dim_person_id
, lcs.civ_career
, lcs.civ_term_id
, lcs.event_ts
, lcs.prediction AS current_prediction
, fcs_shift_7.prediction AS previous_prediction_7_days
, fcs_shift_1.prediction AS previous_prediction_1_day
FROM latest_continuation_score lcs
LEFTJOIN data_mart.fact_continuation_scores fcs_shift_7 ON
This query calculates the average prediction score of students across different age buckets and counts the number of students in each bucket, based on the most recent persistence score date.
This query aims to provide a list of students who have recently dropped at least one course in the active term and have a low continuation score.
We are considering low prediction scores with values below 0.5. Users are able to adjust the threshold as desired.
WITH latest_continuation_score AS(
SELECT
fcs.dim_person_id
, fcs.civ_career
, fcs.civ_term_id
, fcs.event_ts
, fcs.prediction
FROM data_mart.fact_continuation_scores fcs
WHERE fcs.event_ts =(
SELECT
MAX(fcs1.event_ts)
FROM data_mart.fact_continuation_scores fcs1
WHERE
fcs.dim_person_id = fcs1.dim_person_id
AND fcs.civ_career = fcs1.civ_career
AND fcs.civ_term_id = fcs1.civ_term_id
)-- This step ensure that the query returns the latest score for each student.
AND fcs.prediction <0.5-- Adjust persistence score threshold as desired here.
This query calculates the average persistence score for each term.
It also includes the average score by course.
Uncomment the WHERE clause filters to limit the results to specific campuses,
institutions, departments, subjects, or catalog numbers as needed.
WITH score_per_student_per_term AS(
SELECT
dp.raw_person_id
, fcs.civ_career
, fcs.civ_term_id
, fcs.prediction
FROM data_mart.fact_continuation_scores fcs
INNERJOIN data_mart.dim_person dp ON
fcs.dim_person_id = dp.dim_person_id
WHERE fcs.event_ts =(
SELECTMAX(fcs1.event_ts)
FROM data_mart.fact_continuation_scores fcs1
INNERJOIN data_mart.dim_person dp1 ON
fcs1.dim_person_id = dp1.dim_person_id
WHERE dp.raw_person_id = dp1.raw_person_id
AND fcs.civ_career = fcs1.civ_career
AND fcs.civ_term_id = fcs1.civ_term_id
)
)
, average_score_per_course AS(
SELECT
ds.civ_course_id
, de.civ_career_id
,AVG(spspt.prediction)AS total_average_score
FROM data_mart.fact_enroll fe
INNERJOIN data_mart.dim_enrollment de ON
fe.dim_enrollment_id = de.dim_enrollment_id
INNERJOIN data_mart.dim_section ds ON
fe.dim_section_id = ds.dim_section_id
INNERJOIN score_per_student_per_term spspt ON
de.raw_person_id = spspt.raw_person_id
AND ds.civ_term_id = spspt.civ_term_id
AND de.civ_career_id = spspt.civ_career
GROUPBY
ds.civ_course_id
, de.civ_career_id
)
SELECT
ds.civ_course_id
, ds.raw_title AS course_title
, dct.civ_term_id
, ac.total_average_score AS all_time_average_score
-- This query identifies students who are currently enrolled (active) and have:
High GPA (3.0 or higher)
Low persistence/continuation score (below 50%)
WITH latest_continuation_score AS(
SELECT
dp.raw_person_id
, fcs.civ_career
, fcs.civ_term_id
, fcs.prediction
FROM data_mart.fact_continuation_scores fcs
INNERJOIN data_mart.dim_person dp ON
fcs.dim_person_id = dp.dim_person_id
WHERE fcs.event_ts =(
SELECTMAX(fcs1.event_ts)
FROM data_mart.fact_continuation_scores fcs1
INNERJOIN data_mart.dim_person dp1 ON
fcs1.dim_person_id = dp1.dim_person_id
WHERE
dp.raw_person_id = dp1.raw_person_id
AND fcs.civ_career = fcs1.civ_career
AND fcs.civ_term_id = fcs1.civ_term_id
)
AND fcs.prediction <0.5
QUALIFY
ROW_NUMBER()OVER(
PARTITIONBY
dp.raw_person_id
, fcs.civ_career
, fcs.civ_term_id
ORDERBY
fcs.event_ts DESC
, fcs.dim_person_id DESC
)=1
)
, cte_gpa AS(
SELECT
dp.raw_person_id
,AVG(fpg.raw_gpa)AS avg_gpa
FROM data_mart.fact_provided_gpa fpg
INNERJOIN data_mart.dim_person dp ON
fpg.dim_person_id = dp.dim_person_id
GROUPBY dp.raw_person_id, fpg.event_ts
QUALIFY
ROW_NUMBER()OVER(
PARTITIONBY
dp.raw_person_id
ORDERBY
fpg.event_ts DESC
)=1
)
, active_students AS(
SELECTDISTINCT
de.raw_person_id
, de.civ_career_id
, de.institution_id
, dct.civ_term_id
FROM data_mart.dim_enrollment de
INNERJOIN data_mart.dim_section ds ON
de.raw_section_id = ds.raw_section_id
INNERJOIN data_mart.dim_career_term dct ON
ds.raw_term_id = dct.raw_term_id
AND de.civ_career_id = dct.civ_career_id
WHERE dct.is_active =1-- Active terms only
AND de.raw_career_id <>'Not Available'
AND de.civ_is_enrolled =1-- Only enrolled students
)
SELECT
dp.raw_person_id
, lcs.civ_career
, lcs.civ_term_id
, lcs.prediction AS continuation_score
,ROUND(cte_gpa.avg_gpa,2)AS avg_gpa
FROM latest_continuation_score lcs
INNERJOIN data_mart.dim_person dp ON
lcs.raw_person_id = dp.raw_person_id
AND dp.raw_eff_ts_end >CURRENT_DATE-- Current/active records only
This query calculates the Student Continuation Prediction by Location.
We will calculate the Continuation Prediction score by city, state, state_flag and zip_code
You can specify an State in which will generate a flag that will specify if the student is In State or Out of State
-- This state is the state that will indicate if the student is 'In State' or 'Out of State'.
WITH institution_state_variable AS(
SELECT'MA'AS institution_state_value
)
, latest_continuation_score AS(
SELECT
dp.dim_person_id
, dp.institution_person_id
, fcs.civ_term_id
, dp.primary_state
, dp.primary_city
, dp.primary_zip
, fcs.event_ts
, fcs.prediction
FROM data_mart.fact_continuation_scores fcs
INNERJOIN data_mart.dim_person dp
ON fcs.dim_person_id = dp.dim_person_id
WHERE fcs.event_ts =(
SELECTMAX(fcs.event_ts)
FROM data_mart.fact_continuation_scores fcs
WHERE fcs.dim_person_id = fcs.dim_person_id
)
)
, continuation_score_by_location AS(
SELECT
lcs.institution_person_id
, lcs.primary_state
, lcs.primary_city
, lcs.primary_zip
,CASE
WHEN lcs.primary_state =(SELECT institution_state_value FROM institution_state_variable)THEN'In State'
-- AND dct.is_active = 1 -- Students from active term only
GROUPBY
lcs.institution_person_id
, lcs.primary_state
, lcs.primary_city
, lcs.primary_zip
, lcs.prediction
)
SELECT
institution_person_id
, primary_state
, state_flag
, primary_city
, primary_zip
, student_persistence_prediction_score
, student_completion_likelihood_category
, avg_persistence_prediction_by_state
, avg_persistence_prediction_by_city
, avg_persistence_prediction_by_zip
FROM continuation_score_by_location
-- WHERE
-- institution_person_id = '<DESIRED_STUDENT_ID>'
-- AND primary_state = '<DESIRED_STATE>'
-- AND state_flag = 'In State'
-- AND primary_zip = '<DESIRED_ZIP>'
-- AND primary_city = '<DESIRED_CITY>'
-- AND student_persistence_prediction_score >= '<PERSISTENCE_PREDICTION>'
Besides that you can change the final select statement and get more details about the continuation prediction scores of
students from a specific city, state, zip_code or in_state group.
Individual feature ranked (IFR) functionality is not included with standard warehouse deployments. If you would like to incorporate IFR, please inquire with Sales.
This query returns the Civitas model features, ranked by importance for the given student.
Specifying <STUDENT_ID> returns the individual feature ranked (IFR) features for the student, ranked by importance. The most important feature has a rank of 1.
Note: This query returns only features for which an IFR value was calculated.
SELECT
fcfl.event_ts AS score_date
, dp.institution_person_id
, dcf.civ_continuation_feature_id
, dcf.civ_continuation_feature_name
, dcf.civ_continuation_feature_description
, fcfl.text_value
, fcfl.int_value
, fcfl.float_value
, fcfl.bool_value
, fci.feature_rank -- Most important will be ranked 1
FROM data_mart.fact_continuation_feature_latest fcfl
Top and Bottom Percentile Section LMS Features Values#
Identifies students' posting frequency, login activity, and academic performance relative to their section peers using z-score percentiles to flag at-risk behaviors.
Provides engagement metrics including bottom/top 20% posting frequency and bottom quartile grades.
WITH feature_values_pivot AS(
SELECT*
FROM
(SELECT
fcfl.dim_person_id
, fcfl.civ_career_id
, dcf.civ_continuation_feature_id
, fcfl.float_value
FROM data_mart.fact_continuation_feature_latest fcfl
INNERJOIN data_mart.dim_continuation_feature dcf ON
Specifying '<STUDENT_ID>' returns the latest 4-year completion prediction for the student. Enrollment flag and actual completion outcome can also be obtained by joining with other tables in the data warehouse.
-- Find the terms a student has an active enrollment in for each of their careers (academic levels).
WITH student_enrollment AS(
SELECTDISTINCT
de.raw_person_id
, de.civ_career_id AS civ_career
, ds.civ_term_id
, de.civ_is_enrolled
FROM data_mart.fact_enroll fe
INNERJOIN data_mart.dim_enrollment de USING(dim_enrollment_id)
fcsl.window_length =4-- Adjust this for the graduation window you would like to use (4 year, 5 year, etc.). To see your configured windows: SELECT DISTINCT window_length FROM data_mart.dim_completion_window;
Average Persistence or Continuation Score by GPA Band#
This query calculates the average persistence prediction by GPA Band
and categorizes the persistence likelihood into five levels:
Very High, High, Moderate, Low, and Very Low.
It also provides the count of students in each GPA Band
used for the aggregated predictions.
You can modify the GPA ranges in the gpa_data CASE statement
as per your requirements.
-- Get the latest persistence prediction for each student
WITH latest_prediction_per_student AS(
SELECT
dp.raw_person_id
, dp.institution_person_id
, fcs.prediction AS latest_prediction
, de.civ_career_id
FROM
data_mart.fact_continuation_scores AS fcs
INNERJOIN
data_mart.dim_person AS dp
ON fcs.dim_person_id = dp.dim_person_id
INNERJOIN data_mart.dim_enrollment AS de
ON dp.raw_person_id = de.raw_person_id
WHERE de.civ_career_id IN('U','G')-- Limit to certain civ_career_id's as desired
QUALIFY
-- Keep only the latest prediction
ROW_NUMBER()OVER(
PARTITIONBY
dp.institution_person_id
ORDERBY
fcs.event_ts DESC
)=1
)
, gpa_data AS(
-- Map students to GPA bands based on their raw GPA values
SELECT
dp.institution_person_id
,CASE
WHEN fpg.raw_gpa >=0.00AND fpg.raw_gpa <0.50THEN'0.0-0.5'
WHEN fpg.raw_gpa >=0.50AND fpg.raw_gpa <1.00THEN'0.5-1.0'
WHEN fpg.raw_gpa >=1.00AND fpg.raw_gpa <1.50THEN'1.0-1.5'
WHEN fpg.raw_gpa >=1.50AND fpg.raw_gpa <2.00THEN'1.5-2.0'
WHEN fpg.raw_gpa >=2.00AND fpg.raw_gpa <2.50THEN'2.0-2.5'
WHEN fpg.raw_gpa >=2.50AND fpg.raw_gpa <3.00THEN'2.5-3.0'
WHEN fpg.raw_gpa >=3.00AND fpg.raw_gpa <3.50THEN'3.0-3.5'
WHEN fpg.raw_gpa >=3.50AND fpg.raw_gpa <4.00THEN'3.5-4.0'
WHEN fpg.raw_gpa >=4.00THEN'>= 4.0'
ENDAS gpa_band
FROM
data_mart.dim_person AS dp
INNERJOIN
data_mart.fact_provided_gpa AS fpg
ON dp.dim_person_id = fpg.dim_person_id
QUALIFY
ROW_NUMBER()OVER(
PARTITIONBY
dp.institution_person_id
ORDERBY
fpg.event_ts DESC
)=1
)
, plan_stats AS(
-- Calculate average persistence prediction and student count per GPA band
SELECT
gd.gpa_band
, lpps.civ_career_id
,AVG(lpps.latest_prediction)AS avg_prediction_per_band -- Average persistence prediction
,COUNT(DISTINCT gd.institution_person_id)AS student_count -- Count of distinct students
FROM
latest_prediction_per_student AS lpps
INNERJOIN
gpa_data AS gd
ON lpps.institution_person_id = gd.institution_person_id
WHERE
lpps.raw_person_id IN(
-- Filter for active enrollments
SELECTDISTINCT de.raw_person_id
FROM
data_mart.dim_enrollment AS de
INNERJOIN
data_mart.dim_section AS ds
ON de.raw_section_id = ds.raw_section_id
INNERJOIN
data_mart.dim_career_term AS dct
ON ds.raw_term_id = dct.raw_term_id
WHERE
dct.is_active =1-- Only active terms
AND de.raw_career_id <>'Not Available'-- Exclude invalid career IDs
AND de.civ_career_id IN('U','G')-- Limit to certain civ_career_id's as desired
AND de.civ_is_enrolled =1-- Only currently enrolled students
This query calculates the average continuation prediction score
for Domestic, International, and Unknown students. It uses the latest prediction
for each student and only includes students with active enrollments.
WITH latest_prediction_per_student AS(
-- Get the latest persistence prediction for each student
SELECT
dp.raw_person_id
, dp.institution_person_id
, dp.raw_country_of_origin
, fcs.prediction AS latest_prediction
, fcs.civ_career
FROM data_mart.fact_continuation_scores AS fcs
INNERJOIN data_mart.dim_person AS dp
ON fcs.dim_person_id = dp.dim_person_id
QUALIFY ROW_NUMBER()OVER(
PARTITIONBY
dp.institution_person_id
ORDERBY
fcs.event_ts DESC
)=1
)
, active_students AS(
-- Filter for students with active enrollments
SELECTDISTINCT
de.raw_person_id
, de.civ_career_id
FROM data_mart.dim_enrollment AS de
INNERJOIN data_mart.dim_section AS ds
ON de.raw_section_id = ds.raw_section_id
INNERJOIN data_mart.dim_career_term AS dct
ON ds.raw_term_id = dct.raw_term_id
WHERE
dct.is_active =1
AND de.raw_career_id <>'Not Available'
--AND de.civ_career_id IN ('U', 'G') -- Limit to certain civ_career_id's as desired