I am trying to figure out how to pull the data from two tables where I can return firstname, lastname, item, price and the % of total price for each customer.
Two tables:
Customers (customerid, firstname, lastname, city, state)
Items_ordered ( customerid,ordered_date,item,quantity,price)
This statement will only return the first customer. How can you get a SQL statement that will go row by row and return all the information?
SELECT firstname, lastname, price, price/SUM(price)
FROM customers C
JOIN items_ordered O ON (C.customerid=O.customerid);