I have a sql table basicly like this :
As you can see, there is data which uses same ProductID(1002 and 1004). My expectation of this table to become summed and merged with the rows of same ProductID.
I'm using c# and dataGridView. Can we sum those values via sql query then load it onto dataGridView ? or I must create a if - for etc.. statements to check & sum dataGridView rows ?
Edit :
For David's answer :
select * from tblOrderDetail where OrderID in
(select OrderID from tblOrders whereCustomerID = 231234)
// Select * at start gets the ProductID and Quantity
How I can add your solution to this ? when I tried couple things I had errors about using "in" Clause.
SELECT productID, SUM(Quantity) AS Quantity
FROM myTable
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.