如果 tba中
id passnum
1 67
2 NULL
3 80tbb中
id gradenum
1 60.5
2 60
2 NULL
3 90
想当 tba中passnum为NULL时 得到 Y
passnum有值时 如果tbb的gradenum大于tba中passnum为Y否则为N
select case passnum when is null then 'Y' when passnum>gradenum then 'Y' else 'N' end
from tba a,tbb b
where a.id=b.id
这样写都不行,得怎么写?passnum 和gradenum都是decimal(18, 1)
id passnum
1 67
2 NULL
3 80tbb中
id gradenum
1 60.5
2 60
2 NULL
3 90
想当 tba中passnum为NULL时 得到 Y
passnum有值时 如果tbb的gradenum大于tba中passnum为Y否则为N
select case passnum when is null then 'Y' when passnum>gradenum then 'Y' else 'N' end
from tba a,tbb b
where a.id=b.id
这样写都不行,得怎么写?passnum 和gradenum都是decimal(18, 1)
from tba a,tbb b
where a.id=b.id
case when a.passnum is not null and a.passnum<b.gradenum
then 'Y' else 'N' end
from tba a,tbb b
where a.id=b.id
时也为'Y'
case when a.passnum is not null or b.gradenum is null or a.passnum<b.gradenum
then 'Y' else 'N' end
from tba a,tbb b
where a.id=b.id
else (case when passnum>gradenum then 'Y' else 'N' end) end) result
from tba a,tbb b
where a.id=b.id
from tba a,tbb b
where a.id=b.id
(myid int,passnum int)insert into #tba
select 1,67 union all
select 2,null union all
select 3,80create table #tbb
(myid int ,gradenum int)
insert into #tbb
select 1,60 union all
select 2,60 union all
select 2,null union all
select 3,90select myid,case when passnum IS null then 'Y' else
case when passnum<(select top 1 gradenum from #tbb where myid=#tba.myid )
then 'y' else 'n' end
END as rusult from #tba
case when a.passnum is not null or b.gradenum is null or a.passnum<b.gradenum then 'Y' else 'N' end
from
tba a,tbb b
where
a.id=b.id
from tba a,tbb b
where a.id=b.id
from tba a,tbb b
where a.id=b.id