我想從column1+column2(they are calculated columns).
SQL存儲過程,列從其他兩個計算列
Column3 = Column1*.666+Column2*.3333
Column1
和Column2
插入column3
值計算從case語句產生的,他們都很好,但它只是Column3
這是基於 Column1
和Column2
。任何人都可以幫助我如何計算Column3
。
任何幫助,將不勝感激。
在此先感謝
INSERT INTO IF_FUNDDETAILS (D.FUNDCODE, D.FUNDNAME, Column1,Column2, Column3)
SELECT DISTINCT D.FUNDCODE, D.FUNDNAME,
CASE WHEN AVG(FD.INDUSTRYCONTRIBUTIONS)>80 THEN '80' ELSE '90' END AS Column1,
CASE WHEN AVG(FD.BENEFITSCONTRIBUTIONS)>50 THEN '50' ELSE '90' END AS Column2,
FROM DBO.WS_FUNDDETAIL AS D
LEFT OUTER JOIN DBO.V_FUNDNOOUTOFPOCKET AS NOP ON D.FUNDDETAILID = NOP.FUNDDETAILID
INNER JOIN DBO.WS_FUNDDATA AS FD ON NOP.FUNDREPORTID = FD.FUNDREPORTID
GROUP BY D.FUNDCODE, D.FUNDNAME
嘗試添加這些2個案例 –
您是使用MySQL還是SQL Server?有人刪除了MySQL標籤,但也許這是不對的。 –