用下面的方法看看。。
--1.求小于本值的最大值
create function dbo.fn_min_max(@c1 int)
returns int
as
begin
declare @r int
set @r=0
set @r=(select top 1 c1 from a表 a where a.c1<@c1 order by c1 desc )
return @r
end
--2.查询
select c1,c2,dbo.fn_min_max(c1) as min_c1 from b表