Fixing comparison issue and add new SQL.