论坛里看到的一个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
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
一、 SQL DMO 描述:SQL Distributed Management Objects(SQL分布式管理对象),存在于SQLDMO.dll文件中,实际上是一个COM 对象,通过调用SQL DMO的ListAvailableSQLServers方法取得。 列表类型:列举装有“客户端”和“服务端”的计算机。 适用条件:装有 SQL Server,且有SQLDMO.dll文件。 速度:中 调用示例:GetS ......
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 ......
安装的组件和版本的信息
Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services 客户端工具 2005.090.1399.00
Microsoft 数据访问组件 (MDAC) 6.1.7600.16385 (win7_rtm.090713 ......
问题来自http://topic.csdn.net/u/20091128/10/6750afae-71df-42df-ae23-14024736e1d8.html?64174
依我猜测可能是要拼字段名称
if (D > 0)
{
UpData_D = "D_D" + D.ToString();
DataSet myData = Socut.Data.ExecuteDataSet("UPDATE YUAN SET " + UpData_D + "='" + Y + "',..........
}
......