0

我需要基于此执行计算:

(col1 + col2 + col3 + col4 + col5) /col6

完成此计算后,我想根据获得的结果执行 orderby。

请建议。我知道如何执行这样的求和:

SELECT SUM(column1) + SUM(column2) + SUM(columnN) FROM mytable 
4

4 回答 4

1
SELECT (column1+column2+columnN)/column6
FROM mytable
ORDER BY (column1+column2+columnN)/column6
于 2012-11-27T13:23:20.033 回答
1

我想你的意思是:

SELECT ((column1 + column2 + columnN) / column6) as calc 
FROM mytable order by calc
于 2012-11-27T13:24:39.097 回答
1
SELECT (col1 + col2 + col3 + col4 + col5) /col6 as calculated
FROM your_table
ORDER BY calculated
于 2012-11-27T13:25:16.277 回答
0

试试这个 ::

SELECT (column1+column2+columnN) as total,
total/column6 as average
FROM mytable
ORDER BY total
于 2012-11-27T13:24:41.593 回答