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

查询班级中及格,一般,优秀的人数的sql语句

select a.ClassName,a.CourseName,sum(不及格) as 不及格,sum(差) as 差,sum(中等) as 中等,sum(好) as 好 ,sum(不及格)+sum(差)+sum(中等)+sum(好) as 班级总人数 from (select StudentID,ClassName,CourseName,1 as 不及格,0 as 差,0 as 中等,0 as 好 from StudentScore where ScoreRemark='fail' union all
select StudentID,ClassName,CourseName,0 as 不及格,1 as 差,0 as 中等,0 as 好 from StudentScore where ScoreRemark='low' union all
select StudentID,ClassName,CourseName,0 as 不及格,0 as 差,1 as 中等,0 as 好 from StudentScore where ScoreRemark='medium' union all 
select StudentID,ClassName,CourseName,0 as 不及格,0 as 差,0 as 中等,1 as 好 from StudentScore where ScoreRemark='good'  )a group by ClassName,CourseName
      在这里需要注意的是要给某些字段加别名以示区别!


相关文档:

SQL Server 2005 中的Row_Number()函数

本文来自:http://www.cnblogs.com/digjim/archive/2006/09/20/509344.html
 我们知道,SQL Server 2005和SQL Server 2000 相比较,SQL Server 2005有很多新特性。这篇文章我们要讨论其中的一个新函数Row_Number()。数据库管理员和开发者已经期待这个函数很久了,现在终于等到了!
 通常,开发者和管理员在一个 ......

SQL 字符串函数小总结

练手,每天查看别人的东西,不如自己总结好
1:replace 函数
第一个参数你的字符串,第二个参数你想替换的部分,第三个参数你要替换成什么
select replace('lihan','a','b')
                      &nb ......

怎么将下面的sql改成Hql?

select * from ((select bill.id billId,bach.riskRate risk,bach.assureRate assure from AcptBillInfo bill,AcptBach  bach where bill.acptBatchId=bach.id and bill.rgctId=? )abach left outer join AcptSignMoney sig on abach.billId = sig.billId) ......

SQL里的主键和外键

这个逻辑关系乍看起来比较复杂,弄清楚了就好!
有两个表,
student(
id,
name,
primary key (id)
);
studentInfo(
id,
age,
address,
foreign key(id) references outTable(id) on delete cascade on update cascade
);
当我们删除student表的时候自然希望studentInfo里的相关信息也被删除,这就是外键起作用 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号