select case then t1.cnt = t2.cnt then '所有姓张的学生是否都及格了' else '有张姓学生不及格' end from
(select cnt = count(*) from tb where name like '张%') t1,
(select cnt = count(*) from tb where name like '张%' and fs >= 60) t2

解决方案 »

  1.   

    select *,'分数'=case fenshu when fenshu >60 then '及格' else '不及格'end from studentTasble
    where nanme like '%'+@name+'%'---或者
    select * from studentTasble
    where nanme like '%'+@name+'%'
    and fenshu>60
      

  2.   

    select * from Ta t where not exists(select 1 from ta where left(Name,1)=left(t.Name,1) and 分数<60)
      

  3.   

    if (select sum(1)/sum(case when fs > 0 then 1 else 0 end) from tb where name like '张%') = 1 
        print '所有姓张的学生是否都及格了' 
    else
        print '有张姓学生不及格'
      

  4.   

    select count(*) from A where A.a>0 having count(*)>0