fix(query): Fix query for db2, mssql and oracle

related to CAM-910