Brasciole - 6 months ago 49

SQL Question

I'm really struggling with this one. SO I have 2 tables:

- Products
- PendingCartItems

Here's a screenshot of structure for both tables:

I need to get the SUM for all 3 products

`WHERE pending_cart_id = 18`

`SELECT SUM(price) as TotalCartPrice FROM products WHERE id = '274'`

How can I write it so it sums all 3 id's (274+251+49)?

Answer

Would something like this not work?

```
Select sum(b.price*a.quantity)
from pending_cart_items a
join products b
on a.product_id=b.id
where a.pending_cart_id =18
```

**Edit:** Just realized I'd omitted the quantity from the cart computation :)