SONAR-4301 Fix sql query