Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT ROUND((COUNT(client_008.doh_places_updated.id)::numeric(16,2)/
- (SELECT COUNT(x.id)::numeric(16,2)
- FROM client_008.doh_places_updated x
- INNER JOIN PUBLIC.places P ON (X.place_id = P.id)
- INNER JOIN PUBLIC.markets M ON (P.market_id = M.id)
- WHERE (x.doh_date=doh_places_updated.doh_date))::numeric(16,2))*100,2) AS AVG,
- retails.id, retails.name, doh_places_updated.doh_date AS format
- FROM "client_008"."doh_places_updated"
- left join "public"."places" ON places.id = doh_places_updated.place_id
- left join "public"."markets" ON markets.id = places.market_id
- left join "public"."retails" ON retails.id = markets.retail_id
- WHERE "instock_28" = 1 AND
- date_trunc('week',doh_places_updated.doh_date::TIMESTAMP) = date_trunc('week','2017-04-30'::TIMESTAMP)
- GROUP BY 3,2,4 ORDER BY 2,4 ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement