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

论坛里看到的一个SQL问题及解答

问题:
有一个分数表
id classid,score
1  01    120
2  01    128
3  02    98
4  04    134
5  04    78
现在要统计 各班score >120,和大于90分的人数
达到如下效果
classid >120 >90
01    10    29
02    9      32
03    0      20
答案:
select
classid,
sum
(
case
when
score
>
120
then
1
else
0
end
)
as
[
>120
]
,
sum
(
case
when
score
>
90 and score <=120
then
1
else
0
end
)
as
[
>90
]
from
tb
group
by
classid


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

SQL 先筛选在关联的例子

select ID,Item1,Item2,Item3,Item4
into #Temp
from (
select ID='200910',Item1='A',Item2='B',Item3='C',Item4='T1'
union all
select ID='200910',Item1='',Item2='B',Item3='C' ,Item4='G2'
union all
select ID='200910',Item1='A',Item2='D',Item3='C' ,Item4='T3'
union all
select ID='200910',Item ......

Delphi Excel to Sql Server

 unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB,comobj, OleServer,
  ExcelXP;
type
  TForm1 = class(TForm)
    ADOConn: TADOConnection;
& ......

SQL历史与实现

 
在20世纪70年代初期,IBM研究员E. F. Codd博士开创性地研究开发了关系数据模型产品SEQUEL,即结构化英语查询语言(Structured English Query Language)。SEQUEL最终变成了SQL,或结构化查询语言(Structured Query Language,SQL)。
IBM及其他关系数据库的开发厂商都希望有一套能访问并操纵关系数据库的标准化方 ......

经典sql语句

 经典SQL语句大全
下列语句部分是Mssql语句,不可以在access中使用。
  SQL分类:
  DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
  DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
  DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
  首先,简要介绍基础语句:
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号