select  * from table where id not in (select top 50 percent id from table)

解决方案 »

  1.   

    建议你写个存储过程
    先取得  select top 50 percent * from 表名 的数量,然后 select top 数量-1 * from xxx
      

  2.   

    select top 49 percent * from   ??
      

  3.   

    可以根据order by倒序之后取top 50 percent
      

  4.   

    Select top (Select abs(cast(count(1)*0.5 as int)-1) From 表名) * From 表名
      

  5.   


    Select top (Select abs(cast((count(1)-1)*0.5 as int)) From 表名) * From 表名
      

  6.   

    floor函数取小于或者等于的整数值(向下取整),要想只取小于的整数,而不取等于,怎么做?例如:floor(15)的值让它取14;floor(15.3)的值让它取15;floor(15.8)也取15.这个可以实现吗?感谢.
      

  7.   

    select top (49.9999) percent * from但是数据量很少的时候没意义
      

  8.   

    Select top (floor(count(1)*0.5)) * From 表名 where xueqi='1011-2' and xueyuan='学院' order by zongpingfen asc
    报错:
    消息 162,级别 15,状态 1,第 1 行
    TOP 子句中的表达式无效。
    消息 1060,级别 15,状态 1,第 1 行
    TOP 子句中的行数必须是整数。
      

  9.   

    floor函数取小于或者等于的整数值(向下取整),要想只取小于的整数,而不取等于,怎么做?例如:floor(15)的值让它取14;floor(15.3)的值让它取15;floor(15.8)也取15.这个可以实现吗?感谢.
      

  10.   

    select top (ceiling(count(*)*0.4)-1) *,count(*)  from  ceshi where xueqi=@xueqi and xueyuan=@xueyuan order by zongpingfen asc
    报错:top后必须是整数?????????????谢谢。
      

  11.   

    Select top (cast(floor(count(1)*0.5) as int)) * From 表名 where xueqi='1011-2' and xueyuan='学院' order by zongpingfen asc最后再强型转为int就可以了
      

  12.   


    -- 凑个人数。
    -- 别用 *0.5 这个运算了,还得来回转换,直接  / 2 吧, 5 / 2 = 2 ;10 / 2 = 5 ;
    -- (10 - 1 ) / 2 = 4  ; (15 - 1 ) / 2 = 7 ;
    select top (select ( COUNT(*) -1 ) / 2 from sysobjects) * from sysobjects