Sobes.tech
Middle

1. Siparişler: - order_date datetime NULL değil - user_id int NULL değil - order_id int NULL değil 2. Ürünler: - order_id int NULL değil - model int NULL değil - cat_1 varchar(50) NULL değil - price int NULL değil - quantity int NULL değil cat_1 değerleri: - Giyim - Ayakkabı - Kozmetik - Ev eşyaları - Oyuncaklar 2021 yılında "Giyim" kategorisinde ve 2022 yılında "Ayakkabı" kategorisinde olan siparişlerin ve "gerekli kategori ürünlerinin" sayısını gösterin (son hali: 2 satır. Alanlar: yıl, ürün sayısı, sipariş sayısı) with cte as( select year(o.order_date) as year_orders, g.cat_1, count(distinct o.order_id) as count_orders, sum(g.quantity) as count_quan from Orders o join Goods g on o.order_id = g.order_id where g.cat_1 = 'Giyim' and Year(o.order_date) = 2021 or g.cat_1 = 'Ayakkabı' and Year(o.order_date) = 2022 group by year_orders, g.cat_1 ) select year_orders, count_quan, count_orders from cte