为每个'T'提取具有较小序列号的'B'记录,并且大于用于提取每个字段的先前'T'记录的序列

时间:2017-10-25 15:09:42

标签: mysql sql oracle hiveql impala

大家好我正在尝试编写一个sql,用于从登陆表中检索记录并加载到hive目标表。请在下面找到着陆表记录。

file_data,file_name
A0000000010000000100000001717,sample_1 
B0000000020000000100000015000,sample_1 
B0000000020000000100000015000,sample_1 
T0000000050000000100000000000,sample_1 
Z0000000060000000100000000000,sample_1 
A0000000010000000100000001717,sample_2
B0000000020000000100000015000,sample_2
T00000000300000001000000 0000,sample_2
B0000000040000000100000015000,sample_2
T00000000500000001000000 0000,sample_2
Z0000000060000000100000000000,sample_2

我在登陆表中有两列,例如file_data和file_name。每行第10个位置,您可以看到序列号,如1,2,2,5,6等。 我需要“提取'B'记录,每个'T'的序列号较小,并且大于前一个'T'记录的序列,用于提取每个字段” 什么是最好的方法?。请提供示例代码。感谢

0 个答案:

没有答案