i have a sql homework. i Have built a small database with 3 tables(in images).I need to select customer names that have purchased for more than 100 within last month.All purchases are separated.
I tried using using SUM
SELECT customer.CustomerName
FROM customer INNER JOIN
sales
ON customer.id=sales.CustomerId
HAVING SUM(sales.SalesPrice > 100)
In my database there are customers that the sum of Sales price is greteater than 0 but SQL return blank outputenter image description here
Try this:
SELECT customer.customerName FROM customer
INNER JOIN sales ON customer.id = sales.customerId
GROUP BY customerName
HAVING SUM(sales.SalesPrice) > 100;