Changes between Version 7 and Version 8 of WikiStart/Analytics


Ignore:
Timestamp:
03/30/25 21:26:19 (2 months ago)
Author:
203206
Comment:

db

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart/Analytics

    v7 v8  
    161161LIMIT 3;
    162162}}}
     163
     164== Корисници со највисок износ на депозити
     165
     166{{{
     167
     168WITH deposit_totals AS (
     169    SELECT account_id, SUM(amount) AS total_deposit
     170    FROM deposit
     171    GROUP BY account_id
     172)
     173
     174SELECT a.id AS account_id,
     175       a.username,
     176       a.email,
     177       COALESCE(dt.total_deposit, 0) AS total_deposit,
     178       RANK() OVER (ORDER BY COALESCE(dt.total_deposit, 0) DESC) AS deposit_rank
     179FROM account a
     180LEFT JOIN deposit_totals dt ON a.id = dt.account_id
     181ORDER BY deposit_rank
     182LIMIT 3;
     183}}}