declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as mostselect * from @ghy_table
where @ghy_table.maxvalue is not null
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as mostselect * from @ghy_table
where @ghy_table.maxvalue is not null
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as mostselect * from @ghy_table A
where A.maxvalue is not null
declare @sql varchar(1000)
set @ghy_table='(select maxvalue=(case when ghy1>ghy4 then a end) from a ) AA'
set @sql='select * from '+ @ghy_table+' where AA.maxvalue is not null'exec (@sql)
必须声明变量 '@ghy_table'。
出错啊,,where A.maxvalue is not null在最后一条中出错的,怎么办啊??
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as mostselect * from @ghy_table
where @ghy_table.maxvalue is not null
是这条语句出错的,怎么办,
--------------------------------------------------------------------
declare @ghy_table table(maxvalue int)
insert @ghy_table
select maxvalue=(case when ghy1>ghy4 then a end) from a as mostselect * from @ghy_table
where @ghy_table.maxvalue is not null
-----------------------------------------------------------------改成:
select maxvalue=(case when ghy1>ghy4 then ghy1 end) from a as mostOK..