保单件数分布统计.sql 632 B

1234567891011121314151617181920212223
  1. CREATE TABLE shanglifeecif.bdnum_distribution(
  2. id string,
  3. labelName string DEFAULT NULL COMMENT '保单件数名称',
  4. bdnum string DEFAULT NULL COMMENT '保单件数'
  5. ) COMMENT '保单件数分布'
  6. STORED AS ES
  7. with shard number 10
  8. replication 1;
  9. CREATE OR REPLACE PROCEDURE shanglifeecif.bdnum_distribution() IS
  10. DECLARE
  11. BEGIN
  12. delete from shanglifeecif.bdnum_distribution;
  13. insert into shanglifeecif.bdnum_distribution (
  14. id,
  15. labelName,
  16. bdnum
  17. ) SELECT row_number()over(),t.labelName,t.bdnum FROM (
  18. SELECT si.label25 labelName,count(1) bdnum FROM shanglifeecif.individual si GROUP BY si.label25
  19. ) t
  20. END ;