refactor Database::makeSelectOptions

Created new method for creating the group by/having and order by sql,
this avoids code duplication in each database with a overridden
makeSelectOptions.

This fix the group by/having/order by for DB2/MSSQL to support array
conditions. Fixed the having for Postgres for array conditions.

Change-Id: I0fbcb3e8e68d995d93be0bf3d0a347788a39194a
Merge "refactor Database::makeSelectOptions"