首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

越简单越好!简单的统计,该怎么处理

2012-01-01 
越简单越好!简单的统计表格如下:idnum11121212131314881510....num有可能重复。求:num最小(大)的id数目2/1

越简单越好!简单的统计
表格如下:
id   num
11     12
12     12
13     13
14     88
15   10
..     ..

num有可能重复。

求:num最小(大)的id数目
2/1


[解决办法]
--try
select count(*) from table a where a.num=(select min(num) from table )
group by num

[解决办法]
select count(*) 'num最小的id數目 ' from 表
where id =(select min(num) from 表)

暫時只想到上面的蠢方法

[解决办法]
select count(*) from tablename where num in (select min(num) as num from tablename )

[解决办法]
select count(1) from table a where exists(select 1 from table where num> a.num) group by a.num
[解决办法]
呵呵。。都是正解
[解决办法]
select top 1 * from table order by num asc(/desc) --

热点排行