我需要根据这个进行计算:
(col1 + col2 + col3 + col4 + col5)/ col6
当这个计算完成后,我想根据获得的结果执行一个orderby。
请建议。我知道如何执行这样的总和:
SELECT SUM(column1) + SUM(column2) + SUM(columnN) FROM mytable
答案 0 :(得分:1)
SELECT (column1+column2+columnN)/column6
FROM mytable
ORDER BY (column1+column2+columnN)/column6
答案 1 :(得分:1)
我认为你的意思是:
SELECT ((column1 + column2 + columnN) / column6) as calc
FROM mytable order by calc
答案 2 :(得分:1)
SELECT (col1 + col2 + col3 + col4 + col5) /col6 as calculated
FROM your_table
ORDER BY calculated
答案 3 :(得分:0)
试试这个::
SELECT (column1+column2+columnN) as total,
total/column6 as average
FROM mytable
ORDER BY total