统计优惠券覆盖了多少的商品sku
SELECT
percentile_approx(CAST(amount AS DOUBLE), 0.95, 9999) AS q095,
percentile_approx(CAST(amount AS DOUBLE), 0.94, 9999) AS q094,
percentile_approx(CAST(amount AS DOUBLE), 0.93, 9999) AS q093,
percentile_approx(CAST(amount AS DOUBLE), 0.92, 9999) AS q092,
percentile_approx(CAST(amount AS DOUBLE), 0.91, 9999) AS q091,
percentile_approx(CAST(amount AS DOUBLE), 0.90, 9999) AS q090,
percentile_approx(CAST(amount AS DOUBLE), 0.85, 9999) AS q085,
percentile_approx(CAST(amount AS DOUBLE), 0.80, 9999) AS q080
FROM
(
SELECT
batch_id,
COUNT( *) AS amount
FROM
(
SELECT
batch_id,
item_sku_id
FROM
你的表
GROUP BY
batch_id,
item_sku_id
)
a
GROUP BY
batch_id
)
c
q090分位数(覆盖了90%的商品sku)
这个还要再理解-_-||
SELECT size(split('a#b#c', '#'))
# 3
ht.exec_sql(schema_name='gdm', table_name='test_gdm_job_status_sum', sql=sql, exec_engine='hive',
merge_flag=True, merge_part_dir =['dt='+ date_str], merge_type='mr')