Hive - - 分组求最大,最小(加行键)

数据:

1325927 陕西 汉中 084 0849
1325928 陕西 汉中 084 0849
1325930 陕西 延安 084 0842
1325931 陕西 延安 084 0842
1325933 陕西 榆林 084 0845
1325935 陕西 榆林 084 0845
1325941 陕西 西安 084 0841
1325943 陕西 西安 084 0841
1325944 陕西 西安 084 0841
1325946 陕西 西安 084 0841
1325947 陕西 西安 084 0841
1325948 陕西 西安 084 0841
1325949 陕西 西安 084 0841

建表,添加数据

create table if not exists tab4(

no        string,
  province  string,
  city      string,
  pid     string,
  cid     string
)
row format delimited fields terminated by '\t'
stored as textfile;

load data local inpath '/home/data/data4.txt' into table tab4;

求最大
select t.*
from(
select no,province,city,pid,cid,row_number() over(partition by province,city order by pid desc) rk
from tab4) t
where t.rk=1;

求最小:

select t.*
 from(
select no,province,city,pid,cid,row_number() over(partition by province,city order by pid) rk
from tab4) t
where t.rk=1;

查询所有省份,并且分组给city标识列进行排序

select *,row_number() over(partition by province,city order by city) rk
from tab4;

最新文章

  1. Bootstrap模态框按钮
  2. js 获取滚动条的高度 以及 设置滚动条的高度
  3. 学习 ---- JavaScript 高级设计程序 第三章(数据类型)
  4. 1074. Reversing Linked List (25)
  5. JAVA设计模式之解释器模式
  6. UVa 109 - SCUD Busters(凸包计算)
  7. C语言itoa()函数和atoi()函数详解(整数转字符)
  8. DB天气app冲刺第四天
  9. Android编程动态创建视图View的方法
  10. SharePoint 设置Lookup 字段的值
  11. Js 插件修改及优化总结
  12. Splunk
  13. Kali Linux 装好系统后安装经常使用软件
  14. RDO Stack: Failed connect to server
  15. javax.net.ssl.SSLException: Certificate doesn't match any of the subject alternative names
  16. skype客户端搜不到联系人解决办法
  17. ios中Pldatabase的用法(2)
  18. [转]微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)
  19. PHP OAuth 2.0 Server
  20. Delphi XE8帮助中的REST相关内容。

热门文章

  1. CentOS7运行报错kernel:NMI watchdog: BUG: soft lockup - CPU#0 stuck for 26s
  2. 【编程基础】C语言常见宏定义
  3. [20180603]Python读写csv
  4. 对于react中的this.setState的理解
  5. 51nod1268 和为K的组合(DFS)
  6. Qt文档阅读笔记-QGraphicsItem::paint中QStyleOptionGraphicsItem *option的进一步认识
  7. opencv学习之路(35)、SURF特征点提取与匹配(三)
  8. mfc双缓冲绘图
  9. Oracle使用——oracle11g安装——Oracle要求的结果: 5.0,5.1,5.2,6.0 6.1 之一 实际结果: 6.2
  10. 论文笔记:Siamese Cascaded Region Proposal Networks for Real-Time Visual Tracking