SELECT TO_CHAR(o.DateOrdered,'YYYY') AS Year ,pd.Name ProductName, SUM(ol.QtyOrdered) QtyOrdered
FROM C_OrderLine ol -- 訂購項次
INNER JOIN C_Order o ON ol.C_Order_ID=o.C_Order_ID --訂購單(日期對象等)
INNER JOIN M_Product pd ON ol.M_Product_ID=pd.M_Product_ID --產品資料
WHERE o.AD_Client_ID=11 --企業別
AND o.AD_Org_ID=11 --公司別或事業處別
GROUP BY TO_CHAR(o.DateOrdered,'YYYY'),pd.Name