读书人

数据库有关问题

发布时间: 2012-01-19 00:22:28 作者: rapoo

数据库问题
在一个表中只显示几行
如temp表
tempid 自增列
tempvalue 字段值
tempcount 字段个数
想在这个中选出个数在最多的前4列

[解决办法]
select top 4 * from (select * from temp order by tempcount desc) a
[解决办法]
select top 4 *
from temp
order by tempcount desc

读书人网 >SQL Server

热点推荐