FIX use sqlquery for building sort query