日期:2014-05-19  浏览次数:20704 次

30分请教,我这条语句错在哪里?
我想统计数据库里,哪种产品的数量最多.(前10位)

我用下面的SQL语句:

select   Top   10     parts   ,count(parts)as   total    
from   information    
group   by   parts

结果如下:

parts total
1010101 95
1010102 65
1010104 185
1010105 1
1010106 44
1010107 21
1010108 1
1010114 2
1010115 8
1010500 228


可是结果却不对.

因为数据库内象   1510102   /1510104   这样的产品数据有的共有100多条,为什么却没有统计进来?

------解决方案--------------------
select parts ,count(parts)as total
from information
group by parts

------解决方案--------------------
select Top 10 parts ,count(parts)as total
from information
group by parts
Order By total Desc --加上這個
------解决方案--------------------
--LZ沒有加order by ,就默認order by part了
select Top 10 parts ,count(parts)as total
from information
group by parts
order by total Desc