XWI@0CX2WKK0`(}()HQ)IC1.png
    ![$[R9%()RRI4@(%SH[)C2FM.png](https://cdn.nlark.com/yuque/0/2022/png/25786324/1647155523695-4cda4661-a368-4b30-86ba-e6ecca94f5dc.png#clientId=u85b4d441-37f4-4&crop=0&crop=0&crop=1&crop=1&from=ui&id=u943099dc&margin=%5Bobject%20Object%5D&name=%24%5BR9%25%28%29RRI4%40%28%25SH%5B%29C2FM.png&originHeight=447&originWidth=886&originalType=binary&ratio=1&rotation=0&showTitle=false&size=22971&status=done&style=none&taskId=ua7751f27-37f1-4027-9bae-b8d77942926&title=)
    (DP($V$_0$RQQBL8P2C}M$S.png


    这一题需要用到 RECURSIVE 递归查询

    1. WITH RECURSIVE t AS (
    2. SELECT 0 as n
    3. UNION ALL
    4. SELECT n+1 FROM t WHERE n <
    5. (SELECT count(*) FROM Transactions GROUP BY user_id,transaction_date
    6. order by count(*) desc limit 1)
    7. )
    8. SELECT n transactions_count, count(cnt) visits_count FROM t
    9. LEFT JOIN
    10. (
    11. SELECT count(transaction_date) cnt FROM Visits V LEFT JOIN Transactions T
    12. ON (V.user_id,visit_date) = (T.user_id,transaction_date)
    13. GROUP BY V.user_id,visit_date
    14. ) A
    15. ON n = cnt GROUP BY n