开发者

order by in sql after subtracting column values

i've a sql table with 3 columns: id, start, end

i've to select all(SELECT *) the results and arrange them descending from the (start-end) value..

can i do that in a single sql command? any开发者_运维技巧 help?


Use:

SELECT t.id,
       t.start,
       t.end,
       t.start - t.end AS difference
  FROM TABLE t
ORDER BY difference DESC
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜