阅读背景:

SQL SERVER 获取差值最小的数据

来源:互联网 

       分享一个小技巧,获取和自己差值最小的数据,测试数据如下:

--测试数据
if not object_id(N'Tempdb..#T1') is null
	drop table #T1
Go
Create table #T1([code] int,[value] int)
Insert #T1
select 1,10 union all
select 2,50 union all
select 3,100
GO
if not object_id(N'Tempdb..#T2') is null
	drop table #T2
Go
Create table #T2([code] int,[value] int)
Insert #T2
select 1,15 union all
select 2,35 union all
select 3,45
Go
--测试数据结束--测试数



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: