排序问题------急!!! 如果我按照产量汇总,然后加一列,这列按照汇总产量的大小排上序号. 请问我应该怎么做呢??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果我按照产量汇总,然后加一列,这列按照汇总产量的大小排上序号. 请问我应该怎么做呢???-------------select id,sum(qty)as qty from t group by idorder by sum(qty) order by 後可以接一些函數,排序 select 序號,sum(產量)as qty from t group by 序號order by sum(產量) 其实是这样的,原来的表的内容docdate matcode digit --列名 2007.05.01 num2 102007.05.02 num2 202007.05.03 num1 402007.05.04 num1 50需要的效果是序号 matcode 产量1 num2 302 num1 90 --如果不需要第一列Select matcode, SUM(digit) As 产量 From 表 Group By matcode --如果需要第一列,需要借助臨時表Select ID = Identity(Int, 1, 1), matcode, SUM(digit) As 产量 Into #T From 表 Group By matcodeSelect * From #TDrop Table #T select id=identity(int,1,1), matcode,sum(digit)as total into #t1 from #t group by matcode order by sum(digit) id matcode total ----------- -------------------- ----------- 1 num2 302 num1 90(2 row(s) affected) 初学者,希望高人指点 【!菜鸟MM又来提问啦!简单的日期问题!】 如何查询到判断列 分割字符串函数 怎样修改这个表才规范呢 高难度SQL语句求助! 触发器中使用连接服务器问题 使用何种软件可以查看Sql Server 2k的日志文件.ldf的对表的具体操作日志? 如果要动态生成一个数据集怎么办? 请问一个小问题 有关 not in 的问题 再问一个SQL问题
排上序号. 请问我应该怎么做呢???
-------------select id,sum(qty)as qty from t
group by id
order by sum(qty)
group by 序號
order by sum(產量)
2007.05.01 num2 10
2007.05.02 num2 20
2007.05.03 num1 40
2007.05.04 num1 50需要的效果是
序号 matcode 产量
1 num2 30
2 num1 90
Select * From #T
Drop Table #T
----------- -------------------- -----------
1 num2 30
2 num1 90(2 row(s) affected)