select substr(cardId,1,2),count(*) from _log where time between btime and etime group by substr(cardId,1,2)
select xid, count(*) from (select t.*, substr(cardId, 1, 2) xid from _log t where time between 'YYYYMMDD' and 'YYYYMMDD') group by xid;
select houseHoldId, count(*) num from ( select substr(cardId, 1, 2) houseHoldId from _log where time between v_beginTime and v_endTime ) T group by houseHoldId
select substr(cardId,1,2),count(*)
from _log
where time between btime and etime
group by substr(cardId,1,2)
from (select t.*, substr(cardId, 1, 2) xid
from _log t
where time between 'YYYYMMDD' and 'YYYYMMDD')
group by xid;
from (
select substr(cardId, 1, 2) houseHoldId
from _log
where time between v_beginTime and v_endTime
) T
group by houseHoldId