论坛里看到的一个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 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 ......
Next up in the Inside the Storage Engine series is a discussion of page structure. Pages exist to store records. A database page is an 8192-byte (8KB) chunk of a database data file. They are aligned on 8KB boundaries within the data files, starting at byte-offset ......
以前在安装sql的时候,如此提示,我只要重新启动即可,可是今天重新启动了N次计算机,问题却丝毫没有解决,依然提示这样的话。“以前的某个程序安装已在安装计算机上创建挂起的文件操作。运行安装程序之前必须重新启动计算机。” 只好google以下,最终得知是安装程序在先前的安装过程中 ......
--从Excel文件中,导入数据到SQL数据库中,很简单,直接用下面的语句:
/*===================================================================*/
--如果接受数据导入的表已经存在
insert into 表 select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)
--如 ......
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;
& ......