3
Eai personal blz?
Next I’m using this query:
select
products.id as product_id,
offers.id as offer_id,
companies.id as company_id,
products.title,
(ST_Distance(companies.location, 'POINT(-48.030322 -15.839689)':: geography) / 1000) as distance
from offers
inner join products on offers.product_id = products.id
inner join categories on products.category_id = categories.id
inner join offer_company on offers.id = offer_company.offer_id
inner join companies on offer_company.company_id = companies.id
where
offers.start_at <= '2016-09-02 13:07:31' and
offers.deadline >= '2016-09-02 13:07:31' and
products.category_id in (2) and
ST_DWithin(companies.location, ST_SetSRID(ST_Point(-48.030322,-15.839689), 4326), 30000)
order by 1,2,5
and the result is coming like this:
How do I limit only to the nearest company? This way:
I need to somehow display the nearest offer, however it may be in one or more stores (company_id).
You want the first row of duplicate data?
– Marco Souza
yeah. but that’s right
– RaphaelGodoi