xwiki/xwiki-platform — comment on commit 0e59b3cd2101a81cf3298a5260a36c0a37d46692
File:  line 0
By sdumitriu:

Because some databases only allow "ORDER BY" on a selected column, the final query becomes something like:
select distinct doc.fullName, category.priority from ....
which in theory shouldn't behave differently, since it would still differentiate on the fullName.