select
discountId,
count() as cnt
from _cw_distributed_db.upsf_ods_upb_tbl_market_activity_log_info_ulsp
where transDt >= '2021-07-03 00:00:00' AND transDt < '2021-07-04 00:00:00'
group by discountId
order by cnt desc
LIMIT 100
select count(cnt)
from
(
select
discountId,
count() as cnt
from _cw_distributed_db.upsf_ods_upb_tbl_market_activity_log_info_ulsp
where transDt >= '2021-07-03 00:00:00' AND transDt < '2021-07-04 00:00:00'
group by discountId
order by cnt desc
)
where cnt > 1000
select
count(discountId) as diCount,
countDistinct(cardNo) as cardNoCount,
countDistinct(mobile) as mobileCount,
countDistinct(userId) as userIdCount,
countDistinct(logId) as logIdCount
from _cw_distributed_db.upsf_ods_upb_tbl_market_activity_log_info_ulsp
where transDt >= '2021-07-03 00:00:00' AND transDt < '2021-07-04 00:00:00';