I have a table that looks somewhat like this:
Table:Orders
OrderID ProductID Quantity StoreID OrderDate
01 1 5 1 05-10-2014
02 2 2 4 05-10-2014
03 1 1 3 05-10-2014
04 3 1 3 05-10-2014
Now i want to retrieve from above table "orders" data looks like this :
Retrieve Result
ProductID Quantity StoreID OrderDate
(Product Merge) (SUM) (COUNT) (Date*)
1 6 2 05-10-2014
2 2 1 05-10-2014
3 1 1 05-10-2014
As per above "retrieve result" i want to merge my table "orders" data with ProductID
Thanks in advance
If I understood you correctly, you need GROUP BY
. You group them by the productID and select the sum of the quantities
SELECT SUM(Quantity), COUNT(StoreID), ... FROM Orders GROUP BY ProductID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.