Sql query to display all products in order of their daily sales
<p>I have 2 simple tables in my Retail POS app..called products and product_sales. The product_sales records all the sales made in different orders. I want to display a page that lists all my products sorted by the number of their sales...</p>

<p><a href="https://i.stack.imgur.com/2GpnT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2GpnT.png" alt="PRODUCTS"></a></p>

<p><a href="https://i.stack.imgur.com/LYdcI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LYdcI.png" alt="PRODUCT SALES"></a></p>

<p>Now I want to write a SQL query that could fetch all my products ... I think a left join... that could show the sum of all the sales made for that product...and sort them as RANK i.e. top selling Items.</p>

<p><a href="https://i.stack.imgur.com/9qUxx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9qUxx.png" alt="SCREEN"></a></p>

<p>I am a beginner with SQL...and not sure What to write. This is what I tried but not working.</p>

<pre><code>SELECT DISTINCT p1.name,
                p1.id
FROM products p1
LEFT JOIN
product_sales p2
    ON p1.id = p2.product_id
ORDER BY SUM(p2.quantity)
</code></pre>