select top 6 *,(b+c) as sumbc from tablename order by (b+c) desc
select top 6 *,(b+c) as [b+c] from 表名 order by (isnull(b,0)+isnull(c,0)) desc
select top 6 *,(b+c) AS VALUE from table order by (b+c) desc
--注意null与任何值相加都是null create table #tp(a varchar(100),b int,c int)insert into #tp(a,b,c) select '衣服',32,43 union all select '鞋',32,43 union all select '帽子',32,43 union all select '手表',32,43 union all select '手机',32,43 union all select '被子',200,null union all select '鼠标',null,100 --select * from #tpselect top 6 *,(isnull(b,0)+isnull(c,0)) as [b+c] from #tp order by (isnull(b,0)+isnull(c,0)) desc drop table #tp /* a b c a+b --------------------------------------------- 被子 200 NULL 200 鼠标 NULL 100 100 手机 32 43 75 手表 32 43 75 帽子 32 43 75 鞋 32 43 75*/
from 表名
order by (isnull(b,0)+isnull(c,0)) desc
--注意null与任何值相加都是null
create table #tp(a varchar(100),b int,c int)insert into #tp(a,b,c)
select '衣服',32,43 union all
select '鞋',32,43 union all
select '帽子',32,43 union all
select '手表',32,43 union all
select '手机',32,43 union all
select '被子',200,null union all
select '鼠标',null,100 --select * from #tpselect top 6 *,(isnull(b,0)+isnull(c,0)) as [b+c]
from #tp
order by (isnull(b,0)+isnull(c,0)) desc
drop table #tp
/*
a b c a+b
---------------------------------------------
被子 200 NULL 200
鼠标 NULL 100 100
手机 32 43 75
手表 32 43 75
帽子 32 43 75
鞋 32 43 75*/