易截截图软件、单文件、免安装、纯绿色、仅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改成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 Server服务管理器的问题

问题: 一台服务器上运行了SQL Server,SQL Server Agent,Distributed Transaction,Coordinator这三个服务,请问这台服务器是一台什么样的服务器?这三个服务具体有什么作用?
这是一台数据库服务器.
SQL Server 这是主数据库服务,而且形成了SQL Server的支柱。它用于存储和提取数据。
SQL Server Agent 也叫SQL Server代 ......

SQL server子查询

exec xp_cmdshell 'md E:\project'
--先判断数据库是否存在如果存在就删除
if exists(select * from sysdatabases where name='bbsDB')
drop database bbsDB
--创建数据库文件
create database bbsDB
--主数据库文件
 on primary
(
 name='bbsDB_data',--为主要数据库文件命名
 filename='E:\proj ......

操作数据库结构的常用Sql命令(2)

操作数据库结构的常用Sql
下面是Sql Server 和 Access 操作数据库结构的常用Sql,内容由海娃整理,不正确与不完整之处还请提出,谢谢。
新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1)  PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] dateti ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号