That was not my question.
i'm asking how can i achieve this in T-sql 🙂
Reason i want to do this in SQL because these are very heavy queries and want to cache the results.
I in DB field, so can feed fast and consistent presorted data to the web servers, so each server can do what it is best at.
And as far as i know SQL is the place to sort data and not the webserver.