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

KCINFR-979: fixing sql