分组后的排序问题
我用GROUP BY NUM 分组后按升序排列,但NUM是数值型,发现排序后不能按1,2,3,4排列,如何解决问题? 问题点数:20、回复次数:5Top
1 楼Jaron(WWW.JARON.CN)回复于 2004-04-03 02:15:44 得分 0
贴出你完整的SQL语句。Top
2 楼pizixt(皮子)回复于 2004-04-03 03:04:08 得分 20
select count(num) from table Group By num Order By numTop
3 楼mingch()回复于 2004-04-03 10:56:52 得分 0
pizixt你好,谢谢昨晚帮我解决了问题了.
现在的问题是能统计了,但排列不能按数字1,2,3,4,5……排列,好像是字符串排列1,10,……,怎么解决?
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = MM_xl_STRING
Rs.Source = "SELECT count(cl_nu) FROM Product group by cl_nu order by cl_nu "
Rs.CursorType = 0
Rs.CursorLocation = 3
Rs.LockType = 1
Rs.Open()
redim rc(Rs.recordcount+1)
if not Rs.eof then
for i=1 to Rs.recordcount
rc(i)=Rs(0)
Rs.movenext
next
end ifTop
4 楼mingch()回复于 2004-04-03 11:10:07 得分 0
可能是cl_nu在表里的类型是字符型,在SQL查询中能不能转换为数值型再分组,这样能解决吧?但怎么转换呢?Top
5 楼mingch()回复于 2004-04-03 11:11:50 得分 0
问题解决了
SELECT count(cl_nu) FROM Product group by cl_nu order by int(cl_nu )Top




