You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Numbers of orders where payment value is less than 10
%%sql
SELECTCOUNT(order_id) AS orders_payment_value_less_than_10
FROM orders
WHERE EXISTS(SELECT order_id
FROM order_payments
WHEREorders.order_id=order_payments.order_idAND payment_value <10)
%%sql
SELECT ROW_NUMBER() OVER(ORDER BY frequency DESC),
payment_type,
frequency
FROM(SELECT payment_type,
COUNT(order_id) AS frequency
FROM order_payments
GROUP BY payment_type) AS freq
LIMIT10
%%sql
WITH freight AS(SELECT order_id,
price,
freight_value,
CASE WHEN freight_value =0.0 THEN 'FREE'
WHEN freight_value BETWEEN 0.1AND10.0 THEN 'VERY LOW'
WHEN freight_value BETWEEN 10.0AND100.0 THEN 'LOW'
WHEN freight_value BETWEEN 100.1AND200.0 THEN 'MEDIUM'
ELSE 'HIGH'
END AS freight_cost
FROM order_items)
SELECT freight_cost,
COUNT(freight_cost) AS freq
FROM freight
GROUP BY freight_cost
ORDER BY freq DESCLIMIT10
%%sql
WITH prod_cat AS(SELECT DISTINCT(product_category)
FROM products)
SELECT product_category, category_translation
FROM prod_cat AS pc
LEFT JOIN product_translation AS pt
ONpc.product_category=pt.category