易截截图软件、单文件、免安装、纯绿色、仅160KB

这个SQL该如何写

写SQL语句:
表1:CLASS
含有两个字段:ID,CLASSNAME,表结构如下:
ID CLASSNAME
1    A
2    B
3    C
4    D
表2:STUDENT
含有如下字段:SID,NAME,CLASSID
SID是主键,CLASSID是外键,可以通过它和CLASS表作连接。
SID    NAME    CLASSID
01    你        1
02    我        3
03    他        4
........

要求写一SQL语句,查询出A,B,C,D班各有多少学生。
SQL code:

select id,className,'人数'=(select count(1) from student where classid=class.id) from class



SQL code:

SELECT SUM(sid), classid from student GROUP BY classid



不好意思,写错了,是count(sid)

select c.classname,count(s.sid) from class c,student s where c.id=s.classid group by c.classname

SQL code:
select a.classname,b.fc
from (
select classid fcid,count(*) fc
from student
group by classid
) a
left join class b on a.fcid=b.id


SQL code



C


相关问答:

求sql语句将数据库表某些字段的内容翻10倍

数据库某表,想将其中f1,f2两个字段的内容翻10倍,请教如何写法?
update tbl set f1= f1*10,f2= f2*10 where id=10451
这种写法会造成plsql卡死
不会吧,那个id=10451 的数据有多少啊~~~~

我估计sql是不 ......

求sql触发器语句

users表
name  companyId  companyName


company表
companyId  companyName
1          a公司
2          b公司
......

求一sql语句。

表中是这样,
部门号    部门信息
  1        部门一
  2        部门二
  3        部门三
  4& ......

oracle中的to_char,sql server 2005对应的方法是什么

怎么把下面的改成sql server的方法?
to_char(img_comm_metadata.scene_centre_time,'yyyy-mm-dd hh24:mm:ss')>='1990-10-13 09:41:20'
SQL code:
datediff(ss,'1990-10-13 09:41:20',img_ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号