def select_transpose(statement, build_arg = nil)
    rows = select(statement, build_arg)
    return {} if rows.empty?
    field_count = rows.first.size
    if field_count < 2
      raise UnexpectedQueryResult, "must select at least 2 fields in order to transpose"
    elsif field_count == 2
      Doh.array_to_hash(rows) { |row| [row.at(0), row.at(1)] }
    else
      key_field = rows.first.keys.first
      Doh.array_to_hash(rows) do |row|
        value = row.to_h
        value.delete(key_field)
        [row.at(0), value]
      end
    end
  end
def select_transpose(statement, build_arg = nil)
    rows = select(statement, build_arg)
    return {} if rows.empty?
    field_count = rows.first.size
    if field_count < 2
      raise UnexpectedQueryResult, "must select at least 2 fields in order to transpose"
    elsif field_count == 2
      Doh.array_to_hash(rows) { |row| [row.at(0), row.at(1)] }
    else
      key_field = rows.first.keys.first
      Doh.array_to_hash(rows) do |row|
        value = row.to_h
        value.delete(key_field)
        [row.at(0), value]
      end
    end
  end
Rows in the result set must have 2 or more fields.
 If there are 2 fields, returns a hash where each key is the first field in the result set, and the value is the second field.
 If there are more than 2 fields, returns a hash where each key is the first field in the result set,
 and the value is the row itself, as a Hash, and without the field used as a key.