How to select data based on lowest value in a column
The value in the column can be from 1 to 100. I need to select the lowest value.
For example, in table named student contacts there is a column 'primary_contact_priority' which assigns a number value to a student
guardian. This could be a parent, grandparent or otherwise. For some students the value 'primary_contact_priority' may not have a '1'
value but may start at any higher number.
In the table student contacts the column 'contact_person_id' is the guardian assigned id and the 'student_person_id' is the student id.
I've attached the sql code. I need to implement code as needed to select minimum as described above. jk_parent_emails.sql
I might have the partition by column wrong and cannot test this but you get the idea:
Open in new window