Changes between Version 5 and Version 6 of WikiStart/Analytics


Ignore:
Timestamp:
03/30/25 21:11:16 (5 days ago)
Author:
203206
Comment:

db

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart/Analytics

    v5 v6  
    9696}}}
    9797
     98
     99== Прикажи ги корисниците со најголем број на трансфери на пари(број на с-ка, корисничко име, e-mail, број на трансфери и ранг во растечки редослед)
     100
     101{{{
     102WITH transfer_frequency AS (
     103    SELECT t.s_id AS account_id, COUNT(*) AS transfer_count
     104    FROM transfer t
     105    GROUP BY t.s_id
     106
     107    UNION ALL
     108
     109    SELECT t.r_id AS account_id, COUNT(*) AS transfer_count
     110    FROM transfer t
     111    GROUP BY t.r_id
     112)
     113
     114SELECT *
     115FROM (
     116    SELECT a.id AS account_id,
     117           a.username,
     118           a.email,
     119           tf.transfer_count,
     120           RANK() OVER (ORDER BY tf.transfer_count DESC) AS transfer_rank
     121    FROM account a
     122    JOIN transfer_frequency tf ON a.id = tf.account_id
     123) ranked_accounts
     124WHERE transfer_rank <= 3
     125ORDER BY transfer_rank;
     126
     127
     128}}}
     129
     130
     131