重金,请教一个SQl语句!
有3个字段,分别是a,b,c
现在要按d排序
d=a+b+c
如何做?
还有如果d相等,在按b排序。
谢谢
问题点数:100、回复次数:5Top
1 楼jiang130(Hong)回复于 2005-04-02 10:36:19 得分 0
select a,b,c ,d from (select a,b,c,d=a+b+c from 表) a order by d,bTop
2 楼zjcxc(邹建)回复于 2005-04-02 10:39:00 得分 50
select * from 表 order by a+b+c,bTop
3 楼qizhirui(其其)回复于 2005-04-02 10:39:07 得分 50
select a,b,c a+b+c as d
from 你的表
order by d ,b
Top
4 楼zjcxc(邹建)回复于 2005-04-02 10:39:28 得分 0
--如果要考虑null值
select * from 表 order by isnull(a,0)+isnull(b,0)+isnull(c,0),b
Top
5 楼xluzhong(Ralph)回复于 2005-04-02 10:41:22 得分 0
select * from 表 order by isnull(a,0)+isnull(b,0)+isnull(c,0),bTop




