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

【转】 sql统计-关于学生成绩(答案)

sql统计-关于学生成绩(答案)
http://blog.sina.com.cn/s/blog_61380b320100ej9p.html
答案:
1.       计算每个人的总成绩并排名
select name,sum(score) as allscore from stuscore group by name order by allscore
2.   计算每个人的总成绩并排名
select distinct t1.name,t1.stuid,t2.allscore from  stuscore t1,
(
    select stuid,sum(score) as allscore from stuscore group by stuid
)t2
where t1.stuid=t2.stuid
order by t2.allscore desc
3. 计算每个人单科的最高成绩
 select t1.stuid,t1.name,t1.subject,t1.score from stuscore t1,
(
select stuid,max(score) as maxscore from stuscore group by stuid
) t2
where t1.stuid=t2.stuid and t1.score=t2.maxscore
4.计算每个人的平均成绩
select distinct t1.stuid,t1.name,t2.avgscore from stuscore t1,
(
select stuid,avg(score) as avgscore from stuscore group by stuid
) t2
where t1.stuid=t2.stuid
5.列出各门课程成绩最好的学生
select  t1.stuid,t1.name,t1.subject,t2.maxscore from stuscore t1,
(
select subject,max(score) as maxscore from stuscore group by subject
) t2
where t1.subject=t2.subject and t1.score=t2.maxscore
6.列出各门课程成绩最好的两位学生
select distinct t1.* from stuscore t1 
where t1.stuid in 
(select top 2 stuscore.stuid from stuscore where subject = t1.subject order by score desc) 
order by t1.subject
 
7.学号    姓名    语文     数学     英语     总分  平均分
select&nbs


相关文档:

ADO.NET和SQL SERVER数据库中的数据类型对应关系

我们知道,在SQL SERVER中有Bit, Float, Int , Char等等一系列的数据类型,而在DOT NET中,有Boolean,Double,Int 32,String等数据类型与之对应。 也就是说,数据库中的数据类型与DOT NET的数据类型之间,有一个映射关系。下表是他们的映射关系:
 
dot net中的数据类型       &n ......

SQL SERVER2008 下载地址及序列号

SQL Server 2008简体中文企业版下载:
thunder://QUFodHRwOi8vd3d3LnF1aWNrOC5jbi9kb3duLmFzcD9pZD0xMjM2JnNpZD0wWlo=
本DVD包含了x86 x64 ia64 三种CPU模式的安装程序。版本号为: 10.0.1600.22
序列号:
开发版(Developer): PTTFM-X467G-P7RH2-3Q6CG-4DMYB
企业版(Enterprise): JD8Y6-HQG69-P9H84-XDTPG-34MBB ......

Sql时间函数

Sql时间函数
一、sql server日期时间函数
Sql Server中的日期与时间函数 
1.  当前系统日期、时间 
    select getdate()  
2. dateadd  在向指定日期加上一段时间的基础上,返回新的 datetime 值
   例 ......

Sql时间函数

Sql时间函数
一、sql server日期时间函数
Sql Server中的日期与时间函数 
1.  当前系统日期、时间 
    select getdate()  
2. dateadd  在向指定日期加上一段时间的基础上,返回新的 datetime 值
   例 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号