下界 上界 Level 90 100 A 80 90 B 70 80 C 60 70 D 0 60 E这样好么?设两列。。一个下界一个上界
create table #tb2 (Name nvarchar(20), Score float) insert #tb2 select '张三', 90.6 union all select '李四', 87.8 union all select '王五', 53.5 create table #tb1 (下界 int,上界 int, [Level] char(2)) insert #tb1 select 90, 100, 'A' union all select 80, 90, 'B' union all select 70, 80, 'C' union all select 60, 70, 'D' union all select 0 , 60, 'E'select t2.*,t1.[Level] from #tb2 as t2 left join #tb1 as t1 on t2.score between t1.下界 and t1.上界
90 100 A
80 90 B
70 80 C
60 70 D
0 60 E这样好么?设两列。。一个下界一个上界
create table #tb2
(Name nvarchar(20), Score float)
insert #tb2
select '张三', 90.6 union all
select '李四', 87.8 union all
select '王五', 53.5 create table #tb1
(下界 int,上界 int, [Level] char(2))
insert #tb1
select 90, 100, 'A' union all
select 80, 90, 'B' union all
select 70, 80, 'C' union all
select 60, 70, 'D' union all
select 0 , 60, 'E'select t2.*,t1.[Level] from #tb2 as t2
left join #tb1 as t1 on t2.score between t1.下界 and t1.上界