SELECT main.customer_id, ISNULL(Total_points, 0) + ISNULL(Total_points2, 0) AS Total_points_combined
FROM (
SELECT sales.customer_id, SUM(price * 20) AS Total_points
FROM sales
JOIN menu ON sales.product_id = menu.product_id
JOIN members ON sales.customer_id = members.customer_id
WHERE order_date BETWEEN '2021-01-07' AND '2021-01-14'
OR order_date BETWEEN '2021-01-09' AND '2021-01-16'
GROUP BY sales.customer_id
) main
LEFT JOIN (
SELECT sales.customer_id, SUM(price * 10) AS Total_points2
FROM sales
JOIN menu ON sales.product_id = menu.product_id
JOIN members ON sales.customer_id = members.customer_id
WHERE order_date BETWEEN '2021-01-14' AND '2021-01-31'
OR order_date BETWEEN '2021-01-16' AND '2021-01-31'
GROUP BY sales.customer_id
) sub
ON main.customer_id = sub.customer_id
ORDER BY main.customer_id;