I am just trying to simplify a Select statement:
Select (a+b+c)/3 AS V, MIN((a+b+c)/3) as Min, MAX((a+b+c)/3) as Max from ....
Is there a clean way to avoid repeating that formula (a+b+c)/3 in the aggregate functions?
Thanks!
I am just trying to simplify a Select statement:
Select (a+b+c)/3 AS V, MIN((a+b+c)/3) as Min, MAX((a+b+c)/3) as Max from ....
Is there a clean way to avoid repeating that formula (a+b+c)/3 in the aggregate functions?
Thanks!
SELECT
Result/3 AS V,
MIN(Result/3) as Min,
MAX(Result/3) as Max
FROM
(
SELECT (a+b+c) AS Result from Table
) AS outerTable
OR even
SELECT
Result AS V,
MIN(Result) as Min,
MAX(Result) as Max
FROM
(
SELECT (a+b+c)/3 AS Result from Table
) AS outerTable