sknowlton
03/07/2022, 4:00 PMprefrank
) is the placement of each school they chose by geographic distance, i.e. if you applied to the 2nd, 4th, and 5th closest schools, your prefranks are 2, 4, and 5.
We want a field that is just the 'sort order' -- that is, if you chose 2, 4, and 5, we want a field whose value is 1, 2, and 3. Obviously we can manually set and track this any time it changes, but I feel like there is probably also some SQL we could use here to compute a value that says 'the value of prefRankSort
is equal to the row number of this row in the table for this primary key when sorted by prefRank
.' yes? and would that be super expensive to compute?aliaspooryorik
ROW_NUMBER() OVER(PARTITION BY prefRank) AS prefRankSort
ageax
03/07/2022, 4:09 PMPARTITION BY familyId ORDER BY prefRank
sknowlton
03/07/2022, 4:28 PMageax
03/07/2022, 4:31 PMageax
03/07/2022, 4:32 PMsknowlton
03/07/2022, 4:32 PMsknowlton
03/07/2022, 4:32 PMchris_hopkins
03/08/2022, 8:59 AMrow_number()
for pagination/other fun sorting in views and the database isnt dead yet... famous last words