年龄段性别分布统计.sql 733 B

12345678910111213141516171819202122232425
  1. CREATE TABLE shanglifeecif.age_sex_distribution(
  2. id string DEFAULT NULL,
  3. labelname string DEFAULT NULL COMMENT '阶段名称',
  4. gender string DEFAULT NULL COMMENT '性别',
  5. cusnum string DEFAULT NULL COMMENT '客户数量'
  6. )
  7. COMMENT '年龄段性别分布'
  8. STORED AS ES
  9. with shard number 10
  10. replication 1;
  11. CREATE OR REPLACE PROCEDURE shanglifeecif.age_sex_distribution() IS
  12. DECLARE
  13. BEGIN
  14. delete from shanglifeecif.age_sex_distribution;
  15. insert into shanglifeecif.age_sex_distribution (
  16. id,
  17. labelName,
  18. gender,
  19. cusNum
  20. ) SELECT row_number()over(),t.labelName,t.gender,t.cusNum FROM (
  21. SELECT si.label4 labelName,si.gender,count(1) cusNum FROM shanglifeecif.individual si GROUP BY si.label4,si.gender
  22. ) t
  23. END ;