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

http://issues.civicrm.org/jira/browse/CRM-13614
Merge pull request #1834 from monishdeb/CRM-13614

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