SQL 多个字段值相加后排序问题

2024-12-15 10:50:26
推荐回答(5个)
回答1:

很简单,直接在order by后面进行加就可以了:

升序:
select *
from stor
order by (A+B+C+D)

降序:
select *
from stor
order by (A+B+C+D) desc

回答2:

select a+b+c+d as abcd from stor order by abcd ;

回答3:

select *,(A+B+C+D) as sum from stor order by sum

回答4:

select * from stor order by A+B+C+D

回答5:

select (a+b+c+d) as total from stor order by total desc