数据库sql及其解释.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. -- 插入正样本ID 6月
  2. insert into l_pos_uuid_06
  3. select THEMONTH_V, uuid
  4. from ads.Z_USER_TAG_FLAT_out_202106
  5. where uuid in (
  6. select DISTINCT uuid
  7. from ads.Z_USER_TAG_FLAT_out_202107
  8. where THEMONTH_V = '202107'
  9. and EVENT_CPNAME_C = '快手'
  10. and EVENT_ORDER_MONTH_C = '订购1月内'
  11. )
  12. and EVENT_VIDEO_FLUX_V is not null
  13. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视');
  14. -- 109927
  15. select count(1)
  16. from l_pos_uuid_06;
  17. -- 插入正样本ID 7月
  18. insert into l_pos_uuid_07
  19. select THEMONTH_V, uuid
  20. from ads.Z_USER_TAG_FLAT_out_202107
  21. where uuid in (
  22. select DISTINCT uuid
  23. from ads.Z_USER_TAG_FLAT_out_202108
  24. where THEMONTH_V = '202108'
  25. and EVENT_CPNAME_C = '快手'
  26. and EVENT_ORDER_MONTH_C = '订购1月内'
  27. )
  28. and EVENT_VIDEO_FLUX_V is not null
  29. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视');
  30. -- 24213
  31. select count(1)
  32. from l_pos_uuid_07;
  33. -- 插入负样本ID 6月
  34. insert into l_neg_uuid_06
  35. select t0.THEMONTH_V,t0.uuid
  36. from (select THEMONTH_V, uuid
  37. from Z_USER_TAG_FLAT_out_202106 t1
  38. where t1.uuid not in (select uuid from l_pos_uuid_06)
  39. and t1.EVENT_VIDEO_FLUX_V is not null
  40. and t1.EVENT_CONSUM_V < 150
  41. and t1.EVENT_FLUX_C != '30G以上'
  42. and t1.EVENT_VIDEO_FLUX_C != '30G以上'
  43. AND t1.TAG_NETTYPE_C != '2G'
  44. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视')
  45. and position(arrayStringConcat(EVENT_APP_USE.C, ','), '快手') != 0) t0
  46. where t0.uuid in (select DISTINCT uuid
  47. from ads.Z_USER_TAG_FLAT_out_202107
  48. where THEMONTH_V = '202107'
  49. and EVENT_CPNAME_C != '快手'
  50. and EVENT_VIDEO_FLUX_V is not null
  51. and EVENT_CONSUM_V < 150
  52. and EVENT_FLUX_C != '30G以上'
  53. and EVENT_VIDEO_FLUX_C != '30G以上'
  54. AND TAG_NETTYPE_C != '2G'
  55. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视')
  56. and position(arrayStringConcat(EVENT_APP_USE.C, ','), '快手') != 0
  57. );
  58. select count() from l_neg_uuid_06;
  59. -- 插入负样本ID 7月
  60. insert into l_neg_uuid_07
  61. select t0.THEMONTH_V,t0.uuid
  62. from (select THEMONTH_V, uuid
  63. from Z_USER_TAG_FLAT_out_202107 t1
  64. where t1.uuid not in (select uuid from l_pos_uuid_07)
  65. and t1.EVENT_VIDEO_FLUX_V is not null
  66. and t1.EVENT_CONSUM_V < 150
  67. and t1.EVENT_FLUX_C != '30G以上'
  68. and t1.EVENT_VIDEO_FLUX_C != '30G以上'
  69. AND t1.TAG_NETTYPE_C != '2G'
  70. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视')
  71. and position(arrayStringConcat(EVENT_APP_USE.C, ','), '快手') != 0) t0
  72. where t0.uuid in (select DISTINCT uuid
  73. from ads.Z_USER_TAG_FLAT_out_202108
  74. where THEMONTH_V = '202108'
  75. and EVENT_CPNAME_C != '快手'
  76. and EVENT_VIDEO_FLUX_V is not null
  77. and EVENT_CONSUM_V < 150
  78. and EVENT_FLUX_C != '30G以上'
  79. and EVENT_VIDEO_FLUX_C != '30G以上'
  80. AND TAG_NETTYPE_C != '2G'
  81. and EVENT_CATEGORYNAME_C not in ('电商卡', '无限畅视')
  82. and position(arrayStringConcat(EVENT_APP_USE.C, ','), '快手') != 0
  83. );
  84. -------------------------------------------------------------
  85. -- 插入正样本原始数据
  86. insert into l_pos_origin_06
  87. select *,
  88. length(t1.EVENT_APP_USE.C) as I_appuse
  89. from (select *
  90. from Z_USER_TAG_FLAT_out_202106) t1
  91. where t1.uuid in (select uuid from l_pos_uuid_06)
  92. order by I_appuse desc
  93. limit 1 by uuid,t1.EVENT_SPNAME_C;
  94. -- 插入负样本原始数据
  95. insert into l_neg_origin_06
  96. select *, length(t1.EVENT_APP_USE.C) as I_appuse
  97. from (select *
  98. from Z_USER_TAG_FLAT_out_202106
  99. where EVENT_CONSUM_C != '10元以下'
  100. and EVENT_VIDEO_FLUX_C != '未知'
  101. and TAG_NETTYPE_C != '2G'
  102. and position(arrayStringConcat(EVENT_APP_USE.C, ','), '快手') != 0
  103. ) t1
  104. where t1.uuid in (select uuid from l_neg_uuid_06)
  105. order by I_appuse desc
  106. limit 1 by uuid,t1.EVENT_SPNAME_C;
  107. ------------------------------------- 后续用python脚本处理