foo

Original query:

SELECT "rubrics".* FROM "public"."rubrics" LEFT JOIN "public"."rubric_associations" ra2 ON rubrics.id = ra2.rubric_id AND ra2.purpose = 'grading' LEFT JOIN "public"."rubric_assessments" ra3 ON ra2.id = ra3.rubric_association_id WHERE "rubrics"."id" IN (SELECT "rubrics"."id" FROM "public"."rubrics" INNER JOIN "public"."content_tags" ON "content_tags"."content_id" = "rubrics"."id" AND "content_tags"."content_type" = 'Rubric' AND (content_tags.tag_type='learning_outcome' AND content_tags.workflow_state<>'deleted') LEFT JOIN "public"."rubric_associations" ra2 ON rubrics.id = ra2.rubric_id AND ra2.purpose = 'grading' WHERE "rubrics"."context_type" = 'Account' AND "rubrics"."context_id" = 3 AND "content_tags"."workflow_state" = 'active' GROUP BY rubrics.id HAVING (COUNT(rubrics.id) < 2)) AND (ra3.id IS NULL) LIMIT 11