简体   繁体   English

SQL Loader-按组数据加载ID

[英]Sql Loader - Loading id's by group data

Hi I have a flat file which gets dumped into a table by using the sql loader. 嗨,我有一个平面文件,该文件通过使用sql加载程序转储到表中。 Lets say I have a records 可以说我有记录

col1 col2 col3  col4
263 Test1 data  1
263 Test2 data  1
264 Test3 data  2
264 test4 data  2

What I am trying to find out is there any way I can assign sequence number by grouping col1. 我试图找出的是我可以通过将col1分组来分配序列号的任何方法。 If the col1 value is the same then all records should have the same value generated by a sequence. 如果col1值相同,则所有记录应具有由序列生成的相同值。 The function sequence(max,1) generates the next higher value, but how to group the col1 and then assign the same value to them. 函数sequence(max,1)生成下一个更高的值,但是如何对col1进行分组,然后为它们分配相同的值。 Thanks. 谢谢。

You seems want dense_rank() : 您似乎想要dense_rank()

select *, dense_rank() over (order by col1) as seq
from table t;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在通过 SQL 加载器将数据加载到数据库时从日文字符中修剪空格? - How to trim whitespaces from Japanese characters while loading data into DB through SQL Loader? 使用sql loader加载数据时出错。 无法运行程序“sqlldr”:error = 13,权限被拒绝 - Error while loading data using sql loader. Cannot run program “sqlldr”: error=13, Permission denied 如何在通过SQL加载器加载数据和在JSP上显示时组合空单元格 - How to combine empty cells when loading data via SQL loader and displaying on JSP 使用SQL加载器批量插入数据 - Bulk data insertion using SQL loader SQL Derby:GROUP BY未选择ID - SQL Derby: GROUP BY not selected id 春季,Hibernate,JPA:延迟加载ID - Spring, Hibernate, JPA: Lazy loading id's 将sql表数据加载到hazelcast - Loading sql table data into hazelcast 根据相同的 Id 对 arraylist 中的数据进行分组 - group data in arraylist according to same Id 从新的房间持久性库中加载数据时如何显示加载器,并具有失败或成功之类的回调 - How to show loader while loading data from new room persistence library and have callbacks like failure or success Springboot默认数据。sql在启动时未加载 - Springboot default data.sql not loading on startup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM