CRM-13614 fix - SQL query on dynamic group bracking database

Improvised and omitted a bug against https://github.com/civicrm/civicrm-core/pull/1808. This commit includes optimization by replacing the use of $alias variable with $tableAlias parameter itself and excluding extra `` (see at line 2738) which results into DB syntax error earlier.