        INNER JOIN TABLE(name varchar=?) T ON T.`name`=`field`.`name`
        WHERE (`field`.`dataset_id` = ?)) P
    LEFT JOIN `field_score` ON P.id = `field_score`.`field_id` WHERE `field_score`.`i` IN (%s))
-   LEFT JOIN `scores` ON `score_id` = `scores`.`id`")
+   LEFT JOIN `scores` ON `scores_id` = `scores`.`id`")
 
 (defn select-scores-full [dataset-id columns bins]
   (let [q (format field-query

  (subselect field (fields :id) (where {:dataset_id exp})))

(defn- scores-with-fields [fs]
  (subselect field_score (fields :score_id) (where {:field_id [in fs]})))

(defn- clear-by-exp [exp]
  (let [f (fields-in-exp exp)]

    score-id))

(defn- insert-field-score [field-id i score-id]
  (insert field_score (values {:field_id field-id :i i :scores_id score-id})))

(defn- table-writer-default [dir f]
  (f {:insert-field insert-field
