Per live account, the student number a third-party registrar most recently reported registering one of its live completions under, whitespace stripped. Our own mirrored rows are left out: their number came from verified_student_numbers in the first place.
CREATE VIEW study_registry_reported_student_numbers AS (
SELECT DISTINCT ON (r.user_id) r.id AS registered_completion_id,
r.user_id,
regexp_replace((r.real_student_number)::text, '\s'::text, ''::text, 'g'::text) AS student_number
FROM ((course_module_completion_registered_to_study_registries r
JOIN users u ON ((u.id = r.user_id)))
JOIN course_module_completions cmc ON ((cmc.id = r.course_module_completion_id)))
WHERE ((r.deleted_at IS NULL) AND (r.study_registry_registrar_id IS NOT NULL) AND (u.deleted_at IS NULL) AND (cmc.deleted_at IS NULL))
ORDER BY r.user_id, r.created_at DESC, r.id DESC
)| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| registered_completion_id | uuid | true | ||||
| student_number | text | true | ||||
| user_id | uuid | true |
| Name | Columns | Comment | Type |
|---|---|---|---|
| public.course_module_completion_registered_to_study_registries | 10 | Completed course module completion registrations to study registries. | BASE TABLE |
| public.users | 6 | Either students, teachers or staff. | BASE TABLE |
| public.course_module_completions | 18 | Internal student completions for course modules. | BASE TABLE |
Generated by tbls