А
Size: a a a
А
МИ
UPDATE profile.extend set year = year - cl.result from (
select rtb.ag_id, (sum(rtb.points) - COALESCE(rt.plus, 0)) result
from profile.rating_change rtb
left join (
select ag_id, sum(points) plus
from profile.rating_change
where time::date = NOW()::date
group by ag_id, time::date
) rt on rt.ag_id = rtb.ag_id
where time::date = (NOW() - INTERVAL '365 days')::date
group by rtb.ag_id, rtb.time::date, rt.plus
) cl where cl.ag_id = extend.ag_id
KM
СК
А
СК
w
SELECT company_id, COUNT(company_id) as num_of_transactions
FROM company_transactions
GROUP BY company_id
ORDER BY num_of_transactions DESC
А
w
СК
А
СК
СК
w
СК
w
SELECT count(*) as num_of_companies, floor(log(a.num_of_transactions)) as chunk
FROM (
SELECT company_id, COUNT(company_id) as num_of_transactions
FROM company_transactions
GROUP BY company_id
ORDER BY num_of_transactions DESC
) AS a
GROUP BY chunk
w
AK
БК
SD