SELECT
cr.Country,
cr.Region1,
cr.Continent,
le.OverallLifeExpectancy,
le.MalesLifeExpectancy,
le.FemalesLifeExpectancy,
GROUP_CONCAT(DISTINCT i.Ingredient ORDER BY i.Ingredient SEPARATOR ', ') AS IngredientNames,
MAX(i.Category) AS Category -- Get the category for grouping
FROM
country_region cr
INNER JOIN
country_national_dish cnd ON cr.Country_ID = cnd.Country_ID
INNER JOIN
dishes d ON cnd.Dishes_ID = d.Dishes_ID
INNER JOIN
main_contents mc ON d.Dishes_ID = mc.Dishes_ID
INNER JOIN
ingredients i ON mc.Ingredient_ID = i.Ingredient_ID
INNER JOIN
life_expectancy le ON cr.Country_ID = le.Country_ID
WHERE
i.Category IN ('Red meat', 'White meat')
GROUP BY
cr.Country,
cr.Region1,
cr.Continent,
le.OverallLifeExpectancy,
le.MalesLifeExpectancy,
le.FemalesLifeExpectancy
HAVING
COUNT(DISTINCT i.Category) = 1; -- Ensures only one category (Red meat or White meat) is present