Untitled
unknown
pgsql
2 years ago
1.2 kB
7
Indexable
update projects set agent_id = (select agent_id from advertises where project_id = projects.id limit 1) where projects.id is not null update agents set tot_listing = (SELECT COUNT(*) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 1 and advertises."deletedAt" is null ), tot_sell = (SELECT COUNT(*) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 4 and advertises.listing_type = 1 and advertises."deletedAt" is null), tot_rent = (SELECT COUNT(*) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 4 and advertises.listing_type = 2 and advertises."deletedAt" is null), price_min = (SELECT min(price) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 1 and advertises."deletedAt" is null), price_end = (SELECT max(price) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 1 and advertises."deletedAt" is null), price_avg = (SELECT avg(price) FROM advertises where advertises.agent_id = agents.id and advertises.is_publish = 1 and advertises."deletedAt" is null) where agents.id is not null
Editor is loading...
Leave a Comment