自己在其他地方找到解法了。SQL如下:
SELECT
PRODUCT_NO
,SUM(IIF(BUDGET_TYPE='Order',BUDGET_QTY,0)) AS 'B_OrderQties'
,SUM(IIF(BUDGET_TYPE='Order',BUDGET_TWD_AMOUNT,0)) AS 'B_OrderAmt'
,SUM(IIF(BUDGET_TYPE='Sales',BUDGET_QTY,0)) AS 'B_SalesQties'
,SUM(IIF(BUDGET_TYPE='Sales',BUDGET_TWD_AMOUNT,0)) AS 'B_SalesAmt'
FROM BUDGET
GROUP BY PRODUCT_NO