Daily Revenue (JOIN function)


#1

Hello,
Can someone please help me and explain what is the difference between this query:

SELECT DATE(orders.ordered_at), SUM(order_items.amount_paid)
FROM orders, order_items
GROUP BY 1
ORDER BY 1;

and this one:

SELECT DATE(ordered_at), SUM(amount_paid)
FROM orders
JOIN order_items ON orders.id = order_items.order_id
GROUP BY 1
ORDER BY 1;

Why is the "JOIN" function necessary?

Thanks!


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.