Updating query to new DB schema (with workaround).