论坛里看到的一个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
相关文档:
系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......
以前在安装sql的时候,如此提示,我只要重新启动即可,可是今天重新启动了N次计算机,问题却丝毫没有解决,依然提示这样的话。“以前的某个程序安装已在安装计算机上创建挂起的文件操作。运行安装程序之前必须重新启动计算机。” 只好google以下,最终得知是安装程序在先前的安装过程中 ......
1.使用 ESCAPE 关键字定义转义符。 在模式中,当转义符置于通配符之前时,该通配符就解释为普通字符。例如,要搜索在任意位置包含字符串 5% 的字符串,请使用: WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
2.ESCAPE 'escape_character' 允许在字符串中搜索通配符而不是将其作为通配符使用。 escape_character 是放在通配符前 ......
SQL*Loader 用于将大量数据装入数据库。
⑴、定宽数据
创建数据文件control.txt:
aaa,bbb
ccc,ddd
eee,fff
创建控制文件control.ctl:
load data
infile 'c:\loader.txt'
append
into table tester.mm(
m1 position(1:3) char,
m2 position(5:7) char)
批量加载数据:
sqlldr tester/test control=c:\loade ......
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;
& ......