Update functions.sql

Updated view active's order by condition, don't have to do the calc twice