Weld logo
shopify logo
Shopify

Top ten products

Retrieves the top ten products based on the quantity sold. It uses an inner join to combine order lines and orders data and groups the results by product title. The template is limited to only display the top ten products based on the count of orders.
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
Example of output from model:
+----------------------------------+--------+
| 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.

Ready to start modeling your own shopify data?

Get started building your data warehouse with shopify and connect all your apps and databases.

shopify logo
Weld logo
Sign up for free
Weld logo

Tired of scattered data? Sync your data in minutes with our AI-powered ETL platform. Seamlessly connect all your apps, files, and databases.

Backed by leading investors
Frontline logoCherry logoInnnovation Fund logo
Twitter LogoLinkedIn Logo
GDPR logoSOC2
© 2024 Weld. All rights reserved.