用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
hsmserver的公告
<Font size=2 color=green><p>几醉情愁,却饮尽,男儿豪情。<br> 书剑走天涯,独自漂泊。<br> 只当是柔情万般,也逝去多少相思。<br> 莫笑我,梦中总缠绵,怎忘得?<br> 梦残断,情何怨。空伤感,夜难眠。<br> 欲把瑶琴奏,与子偕听。<br> </p></font>
文章分类
友情链接
存档

原创  学习成绩排名 收藏

create talbe score (姓名 varchar(14),科目 varchar(14),分数 int)

insert into score select '张三','数学',85
 union all select '张三','语文',90
 union all select '张三','英语',88
 union all select '李四','数学',87
 union all select '李四','语文',86
 union all select '李四','英语',92
 union all select '王五','数学',90
 union all select '王五','语文',78
 union all select '王五','英语',88

select 姓名,sum( case when 科目='数学' then 分数 end )  as 数学,
            sum( case when 科目='语文' then 分数 end )  as 语文,
            sum( case when 科目='英语' then 分数 end )  as 英语,sum(分数) as 总分 into #s   from score group by 姓名 order by 总分 desc


select *,(select count(distinct 总分) from #s where 总分>=a.总分) as 排名
from #s a
order by 总分 desc

发表于 @ 2006年05月06日 10:07:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:获取星期几的函数 | 新一篇:新婚四夜睡姿

  • 发表评论
  • 评论内容:
  •  
Copyright © hsmserver
Powered by CSDN Blog