LIMIT, check for NULL (IS, IS NOT), GROUP BY, HAVING
LIMIT
-- get first 10 products ordered by unit_price
SELECT product_name, unit_price
FROM products
ORDER BY unit_price DESC
LIMIT 10
Check for NULL
-- Select orders with ship_region
SELECT *
FROM orders
WHERE ship_region IS NOT NULL
GROUP BY
-- Select orders count group by countries
SELECT ship_country, COUNT(*)
FROM orders
WHERE freight > 50
GROUP BY ship_country
ORDER BY COUNT(*) DESC
HAVING (постфильтрация)
SELECT category_id, SUM(unit_price * units_in_stock)
FROM products
WHERE discontinued <> 1
GROUP BY category_id
HAVING SUM(unit_price * units_in_stock) > 5000
ORDER BY SUM(unit_price * units_in_stock) DESC