KCINFR-979: fixing sql
Merge pull request #236 from leoherbie/sql_fix2

KCINFR-979: fixing sql