-- 1. Son bir ay içindeki sipariş vermeyen müşterilerin listesini çıkar.
-- Yapı:
-- customers (customer_id, name, registration_date)
-- orders (order_id, customer_id, order_date, amount)
SELECT DISTINCT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id and o.order_date >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '1 month'
WHERE o.amount IS NULL
-- 2. Kategori toplam gelirinde her alt kategorinin payını hesapla
-- sales (product_id, category, subcategory, revenue, sale_date)
-- Sonuç: category | subcategory | share_of_category