内部表或者ACCESSS
select a.学期,a.学生编号,a.学生姓名,IIF((select Count(b.学生姓名) from {餐费信息} b where b.学生编号=a.学生编号 and b.学期=a.学期)=0,'','√') as 午餐,IIF((select Count(b.学生姓名) from {车费信息} b where b.学生编号=a.学生编号 and b.学期=a.学期)=0,'','√') as 接送,IIF(午餐='√' and 接送='√','红牌',IIF(午餐='' and 接送='','绿牌','黄牌')) as 校牌颜色 from {学费信息} a
MSSQL
select a.学期,a.学生编号,a.学生姓名,case (select Count(b.学生姓名) from {餐费信息} b where b.学生编号=a.学生编号 and b.学期=a.学期) when 0 then '' else '√' as 午餐,case (select Count(b.学生姓名) from {车费信息} b where b.学生编号=a.学生编号 and b.学期=a.学期) when 0 then '' else '√' as 接送, case 午餐='√' and 接送='√' then '红牌' case 午餐='' and 接送='' then '绿牌' else '黄牌' as 校牌颜色 rom {学费信息} a
[此贴子已经被作者于2013-8-17 14:32:39编辑过]