how to custom sort strings
Posted on 2013-09-11
ok i know there are many better ways of doing this, but i just wanna try and push the boundaries and learn a bit.
i've got a table field that is populated by Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday.
there are very few records in this table - just a settings table.
so when i'm querying this table i want to sort it such that monday appears at the top, then tueday, then wednesday etc.
so far the solution i've thought of is using a calculated values column in my query.
switch(field = "monday",1,field = "tuesday",2 ....... etc)
then i will sort on that calculated column.
is there a better way of doing it guys? how would yall do it?
let's just assume that we MUST have the field as text "Monday, Tuesday, Wednesday ...." --> so no cheating by normalising!! hahaha = PP
= )) thanks guys!! = ))