Fix the Grouping and Sorting in secure query in HRMS

Currently it does not group by or sort properly by your choices. You can end up with a group not being all together even if you specify to group by that field, and sorting seems to have a mind of its own instead of sorting in the order you request.

Currently you have to dump the data to excel and use excel to group/sort data.