Skip to content

Instantly share code, notes, and snippets.

@vanpelt
Created November 21, 2008 01:19
Show Gist options
  • Save vanpelt/27303 to your computer and use it in GitHub Desktop.
Save vanpelt/27303 to your computer and use it in GitHub Desktop.
BEGIN;
CREATE TEMP TABLE judged AS
SELECT images.id AS id, images.url AS url, images.created_at AS created_at,
units.#{:norm_ if job.norm}bad_count / units.#{:norm_ if job.norm}judgments_count::decimal AS rating
FROM images LEFT OUTER JOIN units ON units.id = images.unit_id
WHERE (images.job_id = #{job.id} AND (images.grouped IS NOT true AND images.inappropriate))
ORDER BY rating DESC, id;
COPY judged TO STDOUT WITH CSV HEADER;
ROLLBACK;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment