I have a table with a boolean value and I want to find out if a group of id’s have both values.
This sql selects the group of products I want to test:
SELECT
cp.ItemID,
cp.IsUnitsOfMeasure
from grouped_products gp
LEFT JOIN products p ON p.product_id = gp.product_id
LEFT JOIN c_products cp ON cp.ItemID = p.product_id
WHERE gp.group_id=123
I want to find out if cp.IsUnitsOfMeasure for the group contains both 1 and 0.
ContainsBothwill beTRUEorFALSEto indicate whether or not each respective group contains both ac_productwithIsUnitsOfMeasure=0and another with=1.