sql - Oracle / 非技术区
score表
scoreid course studentid score
1 数学 2 99
2 数学 3 60
3 数学 4 80
4 语文 5 79
5 语文 6 58
6 语文 1 66
7 英语 6 76
8 英语 4 87
9 英语 3 100
10英语 2 69
怎样得到没门课中分数最高的那条记录
select * from score a where not exists( select * from score b where a.score<b.score);
select * from score a where not exists( select * from score b where a.score <b.score) group by course;
select * from score a where not exists( select * from score b where a.score <b.score and a.course = b.course);
SQL code:
select t.* from score t where score = (select max(score) from score where course = t.course)
select t.* from score t where not exists (select 1 from score where course = t.course and score > t.score)
select studentid,course,score from (
select studentid,course,score,row_number() over(partition by course order by score desc) rn from score
) where rn = 1
学习了。
SQL code:
WITH tmp_table AS
(
SELECT T.SCOREID,
T.COURSE,
T.SCORE,
T.STUDENTID,
ROW_NUMBER() OVER(PARTITION BY T.COURSE ORDER BY T.SCORE DESC) AS RN
from SCORE T
)
SELECT
ta.SCOREID,
ta.COURSE,
ta.ST
相关问答:
请问一下,外网两台SQLSERVER实例数据传输,有没有采用数据压缩和加密。压缩比是多少,加密是什么加密算法?相关文档哪里可以找到?谢谢
我也想知道!关注此贴!
关注~~
数据库大牛都哪去了啊?
......
我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例:
......
我要做一个定点事件,是每天晚上12点就把三个表里的信息放入一个表里,我想用存储过程来写,怎么写呢?,那位高手帮帮忙吧,非常感谢!
用户名是唯一的
表A 字段
用户名:Name ,邮箱:Ema ......
各位大哥,帮个忙。
下个Oracle for vista 版本的安装试试
10G和11G的
http://www.oracle.com/technology/software/products/database/index.html
------------------------------------------- ......