select identity(int,1,1) as id ,* into #tmp from table
order by col
--先对col排序
declare @max int
select @max=max(id) from distselect * from #tmp
where id between @max/2 and @max/2+(@max+1)%2
order by col
--先对col排序
declare @max int
select @max=max(id) from distselect * from #tmp
where id between @max/2 and @max/2+(@max+1)%2
解决方案 »
- 邹建大哥进,谢谢你刚才的解答
- SQL2000如何写入长文本内容
- 列的说明如何更改?
- 测试SQL
- 求一去除重复数据的sql语句
- 求分组sql
- SQL2000树的递归遍历问题?急呀,救命呀
- 非常简单的菜鸟问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- vf中的远程视图和sql server的编程问题??在线等待!---关注
- 数据库能否自动调用外部应用程序接口并向其传递参数?
- 在线求救:为什么我的SQLSERVER-Manager中的SupportServices->SQL Mail上单击右键打开右键菜单,找不到Start蔡单? 但是配置文件却能测试
- 开发异构数据库用什么工具好?
from dist a cross join dist b
group by a.c1
having (count(case when b.c1<=a.c1 then 1 else null end)>=(count(*)+1)/2)
from dist a cross join dist b
group by a.c1
having (count(case when b.c1<=a.c1 then 1 else null end)>=(count(*)+1)/2)
and (count(case when b.c1>=a.c1 then 1 else null end)>=count(*)/2+1)
还可以这样吧:
调试:
declare @a table (a int)
insert @a select 4 union select 8 union select 10 union select 3 union select 2 union select 15 union select 7 union select 1 union select 6 union select 100 union select 120 select a.a from @a a , @a b group by a.a
having (count(case when b.a<=a.a then 1 else null end)=(count(*)+1)/2)