Untitled

mail@pastecode.io avatar
unknown
pgsql
a year ago
224 B
7
Indexable
UPDATE agents set quota = ( COALESCE((select sum(qty) from orders where agent_id = agents.id and transaction_type = '1' ),0) - COALESCE((select count(id) from advertises where agent_id = agents.id),0) )
where id is not null;
Leave a Comment