I have an SQL I am trying to create in a DatasetAdapter
it works to a certain point but I cant figure out to get the last bit working.
I have a Table(MainTable) with the following Fields: ID Name Image Area Mean
I want to calculation 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
I Then want to get the maximum value of 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
It works so far giving me the maximum value of cal3.
QUESTION: I want to carry out another calculation ( Cal3/maxofcal3). I cant figure it out. I tried code below but came up with an error:
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.