Reputation: 17
I have a table called 2013_orders
The columns I am dealing with are "ordate", "item", and "price". None of these are the primary key of the table.
I have a date select form to select a date range. The tags are "from_date" and "to_date".
In the item column is the part numbers of the part numbers ordered. This column is not restricted to unique values since it'll have multiple instances of the same part numbers.
The ordate column is the order date. This is what I need the date range to look at.
The price column is the price of each part number (item) ordered.
What I need is to have the instances of each part number in the selected date range totaled into one sum for that part number. Then I need The total dollar amount (price) totaled for that part number for that selected date range.
It should display:
Part Number Total Total Price
555111 28 150.23
116000 55 67.88
770-A 151 980.55
.....and so forth
I'm making this post from home and the code variations I have tried are at work, so I don't have an example of an attempt handy. Maybe that's for the best LOL!
Upvotes: 1
Views: 134
Reputation: 72185
This seems like a simple GROUP BY
operation:
SELECT item, COUNT(*) AS Total, SUM(Price) AS Total_Price
FROM mytable
GROUP By item
Upvotes: 5