oracle row_number的使用
create table studentInfo( id number(8) primary key, name varchar2(20) not null, ObjectName varchar2(20) not null, fenshu varchar2(2) not null);insert into studentInfo values(1,'张三','数学',70);insert into studentInfo values(2,'张三','语文',80);insert into studentInfo values(3,'张三','英语',90);insert into studentInfo values(4,'王二','数学',80);insert into studentInfo values(5,'王二','语文',70);insert into studentInfo values(6,'李四','数学',90);insert into studentInfo values(7,'李四','语文',90);1,select name, objectname,fenshu from studentinfo st where fenshu = (select max(fenshu) from studentinfo s where st.objectname=s.objectname);select name,ObjectName, fenshufrom (select name,ObjectName,fenshu, row_number() over(partition by ObjectName order by fenshu desc) rn from studentInfo)where rn = 1SELECT a.NAME,a.Objectname,a.fenshu FROM studentinfo a ,
(SELECT Objectname,MAX(fenshu) fenshu from studentinfo t
GROUP BY Objectname ) b
WHERE a.objectname = b.objectname AND a.fenshu = b.fenshu
oracle row_number的使用的更多相关文章
- oracle row_number() over(partition by .. order by ..)和rank() over(partition by .. order by ..) 和dense_rank() over(partition by .. order by ..)的相似点与区别
新建一个测试表 create table dim_ia_test2(device_number varchar2(20),desc2 varchar2(20)) 插入数据后得到: 一.oracle r ...
- oracle row_number()
要求查询每个用户对应的最大样品信息,忽然想到ms sql提供过 row_number() over(partition by 列 order by 列 desc),那么oracle可能也存在, 我的表 ...
- oracle ROW_NUMBER用法
Oracle中row_number().rank().dense_rank() 的区别 row_number的用途非常广泛,排序最好用它,它会为查询出来的每一行记录生成一个序号,依次排序且不会重复 使 ...
- 问题:oracle ROW_NUMBER()over;结果: ORACLE 中的 ROW_NUMBER() OVER() 分析函数的用法
ORACLE 中的 ROW_NUMBER() OVER() 分析函数的用法 ROW_NUMBER() OVER(partition by col1 order by col2) 表示根据col1分组, ...
- oracle ROW_NUMBER() OVER (PARTITION BY COL1 ORDER BY COL2)
工作中遇到的一个问题,需要对某列进行分组排序,取其中排序的第一条数据项 用到了ROW_NUMBER() OVER(PARTITION BY COL1 ORDER BY COL2)来解决此问题. 实例准 ...
- Oracle row_number() over() 分析函数--取出最新数据
语法格式:row_number() over(partition by 分组列 order by 排序列 desc) 一个很简单的例子 1,先做好准备 create table test1( id v ...
- oracle ROW_NUMBER() OVER(PARTITION BY '分组' ORDER BY '排序' DESC) 用法
转载:https://blog.csdn.net/dbagaoshou/article/details/51330829 SELECT * FROM ( SELECT ROW_NUMBER() OVE ...
- MySQL 实现 Oracle row_number over 数据排序功能
一.方法一GROUP_CONCAT.SUBSTRING_INDEX 1.GROUP_CONCAT 2.SUBSTRING_INDEX 3.例子 首先我们可以首先根据job_id 排序然后根据start ...
- 工作中 sql 整理(一)
这篇文章记录关于SQL的内容,有些凌乱,是工作中点滴的积累,只能按照时间顺序,逐次记录. 一.update 关联更新 1.需求 Table A TableB A表中的主键和B表中的主键相关联,关联 ...
随机推荐
- unity3d easytouch教程
http://www.taikr.com/group/6/thread/1987 说一说easytouch的简单使用方法,和移动平台上的rpg游戏一样,我们肯定也不陌生,我们经常玩游戏的时候用的都是虚 ...
- bzoj 3996: [TJOI2015]线性代数【最小割】
把转置矩阵看成逆矩阵吓傻了233 首先按照矩乘推一下式子: \[ D=\sum_{i=1}^n a[i]*(\sum_{j=1}^n a[j]*b[j][i])-c[i] \] \[ D=(\sum_ ...
- Ionic start 创建项目报错
Installing npm packages... Error with start undefined Error Initializing app: There was an error wit ...
- 基础篇-环境变量 .bash_profile
千里之行始于足下~~~ PGHOST或者PGHOSTADDR PGPORT PGDATABASE PGUSER PGPASSWORD(不推荐使用这个,推荐使用.pgpass)
- Luogu P1074靶形数独【搜索/剪枝】By cellur925
题目传送门 显然是一个搜索.但是开始没有任何的剪枝,暴力从\((1,1)\)点开始搜索,很自然地T了6个点. #include<cstdio> #include<algorithm& ...
- AttributedString 图片间距问题
1.NSMutableAttributedString如何显示图片 NSMutableAttributedString *vipStr = [[NSMutableAttributedString al ...
- F - Balanced Number
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> ...
- A - Beautiful numbers
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> ...
- WKWebView简单使用
#import <WebKit/WebKit.h> @interface SchoolOverviewsViewController ()<WKUIDelegate,WKNaviga ...
- #13:人十我一Orz——6
水题放送,写得依旧丑: #include <cstdio> #include <cstring> #include <cmath> #include <alg ...