我從三個不同的表總和的sql
SELECT lc_orders_tb.lc_orderID, lc_orders_tb.lc_orderSubTotal, lc_orders_tb.lc_orderTotal, lc_orders_tb.lc_orderPlacedDate, lc_tb.lc_compName, lc_tb.lc_addCity, lc_orderQuantity_tb.lc_orderID,
sum(lc_orderQuantity_tb.lc_orderQuantity)
AS lc_orderQuantity
FROM lc_orders_tb, lc_orderQuantity_tb, lc_tb
WHERE lc_orders_tb.lc_id=lc_tb.lc_id
AND lc_orderQuantity_tb.lc_orderID=lc_orders_tb.lc_orderID
GROUP BY lc_orderQuantity_tb.lc_orderID
檢索我要顯示在GridView上面檢索到的值。對於特定的lc_orderID
,只需要對lc_orderQuantity
進行求和,其必須與兩個表匹配,即lc_orders_tb
和lc_orderQuantity_tb
。
有人可以幫我出來嗎..
在此先感謝您。
應指定和/或與您正在使用SQL Server的實際版本標籤;解決方案可能有所不同 –