分类表class
ID ClassName
1    一年级
2    二年级
----------------
学生表Student
ID Name ClassID
1  王明   1
2  李红   1
--------------
如果用一条语句取出下面结果

年级     人数
一年级    2
二年级    0

sql语句:

select  ClassName,(select count(*) from  (select * from Student) As A where A.[ClassID]=B.[ID]) AS 人数  from (select   *   from [class] ) AS B 

 

相关文章:

  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2022-02-08
猜你喜欢
  • 2021-11-29
  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
相关资源
相似解决方案