WITH etc AS (
SELECT
mch_nm,
COUNT(*) AS trx_cnt
FROM cmb_usr_trx_rcd
WHERE
usr_id = 5201314520
AND YEAR(trx_time) IN (2023, 2024)
GROUP BY mch_nm
HAVING COUNT(*) >= 20
),
ds AS (
SELECT
distinct
mch_nm
FROM cmb_usr_trx_rcd
WHERE
usr_id = 5211314521
AND YEAR(trx_time) IN (2023, 2024)
)
SELECT
e.mch_nm AS asshole_tried,
e.trx_cnt,
d.mch_nm as darling_tried
FROM etc e
LEFT JOIN ds d
ON e.mch_nm = d.mch_nm
ORDER BY e.trx_cnt DESC;
WITH etc AS (
SELECT
mch_nm,
COUNT(*) AS trx_cnt
FROM cmb_usr_trx_rcd
WHERE
usr_id = 5201314520
AND YEAR(trx_time) IN (2023, 2024)
GROUP BY mch_nm
HAVING COUNT(*) >= 20
),
ds AS (
SELECT
mch_nm AS darling_tried
FROM cmb_usr_trx_rcd
WHERE
usr_id = 5211314521
AND YEAR(trx_time) IN (2023, 2024)
)
SELECT
e.mch_nm AS asshole_tried,
e.trx_cnt,
d.darling_tried
FROM etc e
LEFT JOIN ds d
ON e.mch_nm = d.darling_tried
ORDER BY e.trx_cnt DESC;
with etc as(
select
mch_nm,
count(*) as trx_cnt
from cmb_usr_trx_rcd
where
usr_id=5201314520
and Year(trx_time) in (2023,2024)
group by mch_nm
having trx_cnt >=20
),
ds as(
select mch_nm as darling_triedfrom cmb_usr_trx_rcd
where
usr_id=5211314521
and Year(trx_time) in (2023,2024)
)
select e.mch_nm as asshole_tried,e.trx_cnt,d.darling_tried
from etc e left join ds d
on e.mch_nm = d.darling_tried
ORDER BY e.trx_cnt DESC;
with etc as(
select
mch_nm,
count(*) as trx_cnt
from cmb_usr_trx_rcd
where
usr_id=5201314520
and Year(trx_time) in (2023,2024)
group by mch_nm
having trx_cnt >=20
),
ds as(
select mch_nm as darling_triedfrom cmb_usr_trx_rcd
where
usr_id=5211314521
and Year(trx_time) in (2023,2024)
)
select e.mch_nm as asshole_tried,e.trx_cnt,d.darling_tried
from etc e left join ds d
on e.mch_nm = d.darling_tried
WHERE d.darling_tried IS NULL
ORDER BY e.trx_cnt DESC;
select
case
when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
when mch_nm rlike '.*(按摩|保健|休闲|养生|SPA|会所).*' then '按摩、保健、休闲、养生、SPA、会所'
end as reg_rules,
count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd where
mch_nm like '%按摩保健休闲%' or
mch_nm rlike '.*(按摩|保健|休闲|养生|SPA|会所).*'
group by reg_rules
order by mch_cnt desc
select
case
when trx_amt = 288 then '1.WithHand'
when trx_amt = 388 then '2.WithMimi'
when trx_amt = 588 then '3.BlowJobbie'
when trx_amt = 888 then '4.Doi'
when trx_amt = 1288 then '5.DoubleFly'
else'6.other'
end as ser_typ,
count(*) as trx_cnt,
min(trx_time) as first_date
from cmb_usr_trx_rcd where mch_nm = '红玫瑰按摩保健休闲' and usr_id = 5201314520
group by ser_typ
order by ser_typ
select
usr_id,
mch_nm,
sum(trx_amt) as trx_amt,
count(*) as trx_cnt,
min(trx_time) as frist_time
from cmb_usr_trx_rcd where usr_id = 5201314520 and trx_amt >=288
group by usr_id, mch_nm
order by trx_cnt desc
select mch_nm from cmb_usr_trx_rcd where usr_id=5201314520
and Year(trx_time) = 2024
and mch_nm in (
selectmch_nm from cmb_usr_trx_rcd where
usr_id=5211314521
and Year(trx_time) = 2024
)
group by mch_nm
select
case
when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
when lower(mch_nm) rlike '.*(按摩|保健|休闲|spa|养生|会所).*' then '按摩、保健、休闲、养生、SPA、会所'
end as reg_rules,
count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%' or lower(mch_nm) rlike '.*(按摩|保健|休闲|spa|养生|会所).*'
group by reg_rules
order by mch_cnt desc
select
case when trx_amt =288 then '1.WithHand'
when trx_amt =388 then '2.WithMimi'
when trx_amt =588 then '3.BlowJobbie'
when trx_amt =888 then '4.Doi'
when trx_amt =1288 then '5.DoubleFly'
else '6.other'
end as ser_typ,
count(*) as trx_cnt,
min(date(trx_time)) as first_date
from cmb_usr_trx_rcd
where mch_nm = '红玫瑰按摩保健休闲' and usr_id = 5201314520
group by ser_typ
order by ser_typ asc
select
case when trx_amt =288 then '1.WithHand'
when trx_amt =388 then '2.WithMimi'
when trx_amt =588 then '3.BlowJobbie'
when trx_amt =888 then '4.Doi'
when trx_amt =1288 then '5.DoubleFly'
else '6.other'
end as ser_typ,
count(*) as trx_cnt,
min(trx_time) as first_date
from cmb_usr_trx_rcd
where mch_nm = '红玫瑰按摩保健休闲' and usr_id = 5201314520
group by ser_typ
order by ser_typ asc
select
usr_id,
mch_nm,
sum(trx_amt) as trx_amt,
count(*) trx_cnt,
min(trx_time) as first_time
from cmb_usr_trx_rcd
where usr_id = '5201314520'
and trx_amt >= 288
group by usr_id,mch_nm
order by trx_cnt desc
select
usr_id,
mch_nm,
sum(trx_amt) as trx_amt,
count(*) trx_cnt,
min(date(trx_time)) as first_time
from cmb_usr_trx_rcd
where usr_id = '5201314520'
and trx_amt >= 288
group by usr_id,mch_nm
order by trx_cnt desc
select
usr_id,
mch_nm,
sum(trx_amt) as trx_amt,
count(*) trx_cnt,
min(date(trx_time)) as first_time
from cmb_usr_trx_rcd
where usr_id = '5201314520'
and trx_amt >= 288
group by usr_id,mch_nm
order by trx_cnt desc
select
usr_id,
mch_nm,
sum(trx_amt) as trx_amt,
count(*) trx_cnt,
min(date(trx_time)) as first_time
from cmb_usr_trx_rcd
where usr_id = 5201314520
and trx_amt >= 288
group by usr_id,mch_nm
order by 4 desc