删除列重复的字符串值并提取库伦值的最大字符串值

时间:2018-12-20 11:20:36

标签: hadoop hive

enter image description here

我想用temp2max tot_duration填充count from temp1。我使用以下代码进行操作:

insert into analytics_db.charith_prepaid_bcell_temp2
(charged_party,cell_id,tot_duration,tband_count)
select  A.*
FROM  analytics_db.charith_prepaid_bcell_temp1  A,
(SELECT A.charged_party,B.B,MAX(A.tot_duration) C-- MAX COUNT FOR MAX TIMA BAND CELL
     FROM  analytics_db.charith_prepaid_bcell_temp1  A,
           (SELECT charged_party,MAX(tband_count) B ---- MAX TIME BAND COUNT
             FROM  analytics_db.charith_prepaid_bcell_temp1 
             WHERE NVL(tot_duration,0) >0
             GROUP BY charged_party) B
     WHERE NVL(tot_duration,0) >0 AND A.charged_party  = B.charged_party  AND A.tband_count = B.B  
     GROUP BY A.charged_party,B.B) C
WHERE A.charged_party = C.charged_party   AND A.tot_duration= C.C AND A.tband_count = C.B

enter image description here

但是temp2中有重复的条目,其中具有相同的tot_durationtband_count的相同的charged_party具有不同的单元格ID。如何修复代码,以仅在只有一个条目的最大cell_id的情况下获取条目?

谢谢

1 个答案:

答案 0 :(得分:1)

这可以通过排名函数<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="SummaryRow"> <h1 id="yett">1000$</h1> </div> <div> <label>-187</label> <input class="switch" type="checkbox" subtractby="187"> </div> <div> <label>-27</label> <input class="switch" type="checkbox" subtractby="27"> </div>来完成。

row_number