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 子句中的行数必须是整数。
select top (ceiling(count(*)*0.4)-1) *,count(*) from ceshi where xueqi=@xueqi and xueyuan=@xueyuan order by zongpingfen asc 报错:top后必须是整数?????????????谢谢。
Select top (cast(floor(count(1)*0.5) as int)) * From 表名 where xueqi='1011-2' and xueyuan='学院' order by zongpingfen asc最后再强型转为int就可以了
先取得 select top 50 percent * from 表名 的数量,然后 select top 数量-1 * from xxx
Select top (Select abs(cast((count(1)-1)*0.5 as int)) From 表名) * From 表名
报错:
消息 162,级别 15,状态 1,第 1 行
TOP 子句中的表达式无效。
消息 1060,级别 15,状态 1,第 1 行
TOP 子句中的行数必须是整数。
报错:top后必须是整数?????????????谢谢。
-- 凑个人数。
-- 别用 *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