fixed criteria order generating database query