Top ten products
1select
2 title
3 , sum(quantity) as amount
4from
5 {{raw.shopify.order_line}} order_lines
6 inner join {{raw.shopify.order}} orders on order_lines.order_id = orders.id
7group by
8 title
9order by
10 count(*) desc
11limit
12 10
+----------------------------------+--------+
| Title | Amount |
+----------------------------------+--------+
| Product A | 100 |
| Product B | 90 |
| Product C | 80 |
| Product D | 70 |
| Product E | 60 |
| Product F | 50 |
| Product G | 40 |
| Product H | 30 |
| Product I | 20 |
| Product J | 10 |
+----------------------------------+--------+
This SQL model works by selecting the title and sum of the quantity of each product sold from the Shopify example order line. It then joins this data with the Shopify example order table to group the products by title and order them by the count of sales in descending order. The result is a list of the top ten best-selling products on your Shopify store. This SQL template can be useful for identifying which products are most popular with your customers, allowing you to optimize your inventory and marketing strategies accordingly. With this information, you can make data-driven decisions to improve your business and increase your sales.