34,590
社区成员
发帖
与我相关
我的任务
分享
--楼上的,这个肯定不行,这个是根据11<=10-5/100.0这个条件判断取值的,和根据公式取值对应不上。
select [分数] from tb where 11<=10-5/100.0
create table [tb]([公式] varchar(13),[分数] int)
insert [tb]
select 'A+10%<B',150 union all
select 'A+5%<B<=A+10%',120 union all
select 'A-5%<B<=A+5%',100 union all
select 'B<=A-5%',50
select * from [tb]
declare @a varchar(5),@b varchar(5)
set @a=10
set @b=11
declare @sql varchar(1000)
set @sql=''
select @sql='select [分数] from tb where '+replace(replace(replace([公式],'A',@a),'B',@b),'%','/100.0') from tb
print @sql
/**
select [分数] from tb where 11<=10-5/100.0
*/