High level:
I have checklists and checklists. I want to get an account of the checklists that have been completed. In particular, checklists that contain checklist items, but they are all complete.
Tables:
Table "checklists" | Column | Type | +--------------+------------------------+ | id | integer | | name | character varying(255) | Table "checklist_items" | Column | Type | +--------------+------------------------+ | id | integer | | completed | boolean | | name | character varying(255) | | checklist_id | integer |
Question: What request will give me completed checklists? In particular, try to exclude checklists that have checklist items that are full and incomplete and a checklist that don't have checklist items.
Tried so far:
SELECT DISTINCT COUNT(DISTINCT "checklists"."id") FROM "checklists" INNER JOIN "checklist_items" ON "checklist_items"."checklist_id" = "checklists"."id" WHERE "checklist_items"."completed" = 't'
The problem with this question is that it does not exclude partially completed checklists.
source share