当前位置: 代码迷 >> Sql Server >> 怎的查询未满人数的考场
  详细解决方案

怎的查询未满人数的考场

热度:89   发布时间:2016-04-24 09:55:50.0
怎样查询未满人数的考场?
考场表kcb,有字段考场kc,考试时间kssj,考试最多人数rs,
人员表ryb,有字段身份证号sfzh,姓名xm,考试时间kssj,
就是说,每个考试时间都有最多人数的限制,现在要查询考试表里,未满考试人数的那些考试时间,
怎样写这个查询语句?
------解决思路----------------------
引用:
Quote: 引用:


select kc,kssj from (
select *,(select count(sfzh)  from ryb where kssj=a.kssj) as ksrs) from kcb as a
) as b where ksrs<rs

关键字from 附近有语法错误

試一下這句sql

select kc,kssj from (
select *,(select count(sfzh) from ryb where kssj=a.kssj)as ksrs from kcb as a
) as b where ksrs<rs
  相关解决方案