Mysql grouping statistics counts all the recharge amounts under each agent

< H2 > user table: user field: id,parentid (the ID,0 of the superior is the top level) < / H2 > < H2 > Statistical report: report field: time,u_id,pay, description: only one row of data is stored per user per day < / H2 > < H2 > user subordinate table: user_lower field: UsingidMagee lowerid, note: this table is all subordinate users storing u_id < / H2 >

count all recharges under a single agent

-sharp
select * from user_lower where u_id = 1
-sharpSQLlowerid
select u_id,sum(pay) from report where u_id in (lowerid)

how can I use SQL to quickly obtain the top-up amount under the agent

Apr.07,2022

will the proxy have multiple layers?


SELECT 
    l.u_id u_id,u.username,
    report.time time,
    SUM(report.pay) pay,
FROM
    `sys_statistics`
        INNER JOIN
    user_lower l ON report.u_id = l.lowerid
        LEFT JOIN
    user u ON u.id = l.u_id
WHERE
    (report.time >= '2000-01-01')
        AND (report.time <= '2019-01-07')
        AND (u.parentid = '12500')
GROUP BY l.u_id
ORDER BY time DESC
LIMIT 30 OFFSET 0
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31686-2b5dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31686-2b5dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?