Transform query results