How to sort DMN result using Camunda API

Hi All,
In our current implementation, We are using below query to get the unique row
select *
from table WHERE upper(imd_code) in (‘45687667’,‘ALL’)
AND upper(user_id) in (‘D9808’,‘ALL’) AND upper(channel)
ORDER BY case when upper(imd_code) = ‘ALL’ then ‘999999’ else imd_code end,
case when upper(user_id) = ‘ALL’ then ‘ZZZZZ’ else user_id end
desc,id desc limit 1;

Now trying to implement CAMUNDA and successfully executing till
select *
from table WHERE upper(imd_code) in (‘45687667’,‘ALL’)
AND upper(user_id) in (‘D9808’,‘ALL’) AND upper(channel)
We have created DMN and executed using CAMUNDA’s API.

But no idea , how to implement ORDER By on evaluated result.
Need your expertise to solve this problem.

Thanks
Deepak Srivastava