易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

MyEclipse连接SQL Server 2000错误排除

在连接SQL Server 2000数据库时,系统提示如下错误:
在网上寻找到处理方法:
(把SQL server update到sp4)
1、在查询分析器中输入 select @@version 并执行
SQL Server 2000 版本和级别
@@VERSION
产品级别
 
SQL Server 2000 原始版本
8.00.194
RTM
 
Database Components SP1
8.00.384
SP1 ......

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语句(ZT)

1.监控当前数据库谁在运行什么SQL语句
SELECT osuser, username, sql_text from v$session a, v$sqltext b
where a.sql_address =b.address order by address, piece;
 
2.分析表
analyze table tablename compute statistics for all indexes;
analyze table tablename compute statistics for all indexed col ......

SQL Server

查询 card 的记录为两次以上的 card,记录数:
select count(card), card from TableName group by card having count(card) > 1
级联更新,级联删除:
ColumnName type not null constraint FK_Name foreign key(ColumnName) references PrimaryTable(ColumnName) on update/delete cascade
自动计算列:
create tabl ......

关于用ADO.NET 获取 SQL SERVER 表 SCHEMA的一些记录

最先希望使用datatable.columns种所含有的属性直接获取相关信息,可测试后发现,除了字段名和字段类型,其他数据一概找不到。
GOOGLE网上很多种方法,其中最直接的是直接查询SQLSERVER的information_schema.colums视图,从中直接获取信息,不过后来又发现,虽然数据时全了,可是需要通过很复杂的方法(sys.all_columns sys ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号