hive数据去重,并根据需求取其中一条
数据案例:
name adx tran_id cost ts
ck 5 125.168.10.0 33.00 1407234660
ck 5 187.18.99.00 33.32 1407234661
ck 5 125.168.10.0 33.24 1407234661
只需要前两行的记录,因为第三行的tran_id和第一行的重复了,所以需要将最后面一行重复的去掉。
方案一:
selectt1.tran_id,t2.name,t2.cost
from (selectdistinct tran_id from table) t1
join table t2 ont1.tran_id=t2.tran_id
分析:
如果使用distinct