玄铁剑

成功的途径:抄,创造,研究,发明...
posts - 128, comments - 42, trackbacks - 0, articles - 174

导航

<2008年2月>
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678

常用链接

留言簿(5)

随笔分类

随笔档案

文章分类

收藏夹

AJAX

asp.net網絡鏈接

Delphi Link

IronPython

Microsoft

Other Blogs

OtherSite

SliverLight

Test

免费asp.net控件

其它链接

搜索

  •  

积分与排名

  • 积分 - 217497
  • 排名 - 26

最新评论

阅读排行榜

评论排行榜

Group by的Top用法

Posted on 2007-04-12 21:57 玄铁剑 阅读(757) 评论(0)  编辑 收藏 引用

create table test1
(a int ,b int ,c int)

insert into test1(a,b,c)
values(1,1,1)

insert into test1(a,b,c)
values(1,1,2)

insert into test1(a,b,c)
values(1,1,3)

insert into test1(a,b,c)
values(1,1,4)

insert into test1(a,b,c)
values(1,2,1)

insert into test1(a,b,c)
values(1,2,2)

insert into test1(a,b,c)
values(1,2,3)

insert into test1(a,b,c)
values(1,2,4)


insert into test1(a,b,c)
values(1,3,1)

insert into test1(a,b,c)
values(1,3,2)

insert into test1(a,b,c)
values(1,3,3)

insert into test1(a,b,c)
values(1,3,4)

SELECT * from test1
select * from test1 where
 c>=(select min(c) from (select top 3 c from test1 t where t.b=test1.b order by c desc)a)

只有注册用户登录后才能发表评论。