34,576
社区成员
发帖
与我相关
我的任务
分享
set @temp='select top '+str(@page_size)+' * from 信息表 where '+@str_where+' order by case when exists(select 1 from 附加条件表 where 信息表.id=id) then (select top 1 附加条件表排序字段 from 附加条件表 where 信息表.id=id) end desc,'+@str_order_by
我原来的
set @temp='select top '+str(@page_size)+' * from 信息表 where '+@str_where+' order by case when exists(select 1 from 附加条件表 where 信息表.id=id) then (select top 1 附加条件表排序字段 from 附加条件表 where 信息表.id=id) end desc,'+@str_order_by
你的
'select top '+str(@page_size) a.*,(select top 1 附加条件表排序字段 from 附加条件表 where id=a.id) as 附加条件表排序字段 from 信息表 a where '+ @str_where +' order by 附加条件表排序字段 desc, '+@str_order_by
按你的修改的
set @temp='select top '+str(@page_size)+' a.*,(select top 1 附加条件表排序字段 from 附加条件表 where id=a.id) as 附加条件表排序字段 from 信息表 as a where '+@str_where+' order by case when exists(select 1 from 附加条件表 where 信息表.id=id) then (select top 1 附加条件表排序字段 from 附加条件表 where 信息表.id=id) end desc,'+@str_order_by
'select top '+str(@page_size) a.*,(select top 1 附加条件表排序字段 from 附加条件表 where id=a.id) as 附加条件表排序字段 from 信息表 a where '+ @str_where +' order by 附加条件表排序字段 desc, '+@str_order_by
'select top '+str(@page_size) a.*,(select top 1 附加条件表排序字段 from 附加条件表 where id=a.id) as 附加条件表排序字段 from 信息表 a where '+ @str_where +' order by (select top 1 附加条件表排序字段 from 附加条件表 where id=a.id) desc, '+@str_order_by