zoukankan      html  css  js  c++  java
  • Hive实现从表中随机抽样得到一个不重复的数据样本

    select a.* 
    from (
    select a.*,rand(12345) as random
    from tripdata a
    ) a
    where random between 0 and 0.2;
    

      

    a.country       a.city  a.visitors      a.random
    阿联酋  迪拜    268     0.3618031071604718
    阿联酋  迪拜    108     0.932993485288541
    澳大利亚        墨尔本  230     0.8330913489710237
    澳大利亚        墨尔本  188     0.32647575623792624
    澳大利亚        堪培拉  378     0.2355237906476252






    select distinct a.*
    from tripdata a
    order by rand(12345) 
    limit 5;
    

     

    country       city  visitors
    阿联酋  阿布扎比        157
    阿联酋  阿布扎比        137
    阿联酋  迪拜    144
    阿联酋  阿布扎比        227
    澳大利亚        堪培拉  240



    select
    	user_log_acct,
    	row_number() over(ORDER BY rand(1000)) as row_num
    from
    	dev.dev_XXX
    

      

    这里,row_number() over(ORDER BY rand(1000)) 中,1000相当于一个随机种子,跑多次,随机的结果是一样的;


    https://www.jianshu.com/p/2b73e7c53355
  • 相关阅读:
    APP测试-流量测试
    APP测试-流畅度测试
    APP测试-耗电分析
    工具安装-Homebrew
    工具安装-go for Mac
    APP测试-耗电量测试
    APP测试-CPU测试
    APP测试-内存测试
    APP测试-monkey
    APP测试-adb命令
  • 原文地址:https://www.cnblogs.com/Allen-rg/p/10433000.html
Copyright © 2011-2022 走看看