1
我有一個SQL我試圖在DatasetAdapter
中創建它工作到某個點,但我無法弄清楚最後一點工作。在SELECT語句中計算錯誤
我有一個表(MainTable)具有以下字段:ID名稱圖像區域平均
我想計算ABS(Area-?) AS Cal1, ABS(Mean-?) AS Cal2 , Cal1+Cal2 As Cal3
SELECT
ID, Image, Name, Area, Mean, ABS(Area - ?) AS cal1, ABS(Mean - ?) AS cal2, Cal1+Cal2 AS cal3
FROM MainTable
我於是想CAL3的最大值
SELECT MAX(cal3) AS maxofcal3
FROM
(SELECT ID, Image, Name, Area, Mean, ABS(Area - ?) AS cal1, ABS(Mean - ?) AS cal2, derivedtbl_1.cal1 + derivedtbl_1.cal2 AS cal3
FROM MainTable)
derivedtbl_1
它迄今爲止工作給我cal3的最大值。
問題: 我想進行另一個計算(Cal3/maxofcal3)。我無法弄清楚。我想下面的代碼,但想出了一個錯誤:
SELECT MAX(Cal3) AS maxofCal3, Cal3/MaxofCal3 AS Norm
FROM (SELECT ID, Image, Name, Area, Mean, ABS(Area - ?) AS cal1, ABS(Mean - ?) AS cal2, derivedtbl_1.cal1 + derivedtbl_1.cal2 AS cal3
derivedtbl_1.Cal1 + derivedtbl_1.Cal2 AS Cal3
FROM MainTable) derivedtbl_1
GROUP BY Cal3/MaxofCal3.
錯誤是什麼? – 2013-03-28 01:11:37