This is all simplified, but should be enough to complete the task :-
I have a primary table;
`providers`
id (bigint)
name
location (point)
radiusKm (int)
I use a stored procedure to retrieve any providers within catchment (simplified);
SELECT id, name, location, degToMeter(st_distance(@checkPoint, location)) AS distance FROM providers WHERE degToMeter(st_distance(@checkPoint, location)) < radiusKm
However, I have now needed to add an additional table to account for additional depots;
`depots`
id (bigInt)
providerId (bigint)
location (point)
radiusKm (smallint)
The procedure must now return all providers that have a depot within the vicinity of a given point. The resulting fields I will need are :-
id - The provider ID
name - The provider name
depotId - ID of the provider's closest depot
location - location of the provider's closest depot
distance - The distance of the checkPoint to the selected depot
So we need a grouping of the depots for each provider, ordered by distance, with only the closest one being returned. i.e. If two depots of a single provider are within catchment, the returned provider would only show the closest one, and not return the same provider twice.
I expect this project to take a suitable candidate and hour at most to complete. I'm looking for something efficient and elegant. Many thanks.
Hello.
Would you need this as a separate procedure to return only depots and their providers?
Do you have the depots table ready?
Would you give me the access to the real database?
I'm ready to start.
Thanks.
Eugene
Hi there,
I am a professional Graphic Designer & wordpress expert with 2+ years experience.
I am also a Student of Software Engineering in Pakistan.
I have read and understand your project Description.
I can make complex SQL complex Queries to insert, fetch, delete and update data from your database.
previous work : Found errors in query
select *, count(distinct vi.views_id) as ViewCount from campaigns cam left join views vi ON vi.views_campaign_id = cam.campaigns_id left join rates ra on
ra.rates_id = cam.campaigns_rates_id where cam.campaigns_budget_used_today < cam.campaigns_daily_budget and cam.campaigns_current_budget > 0
and cam.campaigns_approved = 1 and cam.campaigns_status = 0 and cam.campaigns_payment_accepted = 1 and cam.campaigns_device = 1
or cam.campaigns_device = 0 and ra.rates_location IS NULL group by cam.campaigns_daily_budget having
ViewCount <= cam.campaigns_ordered_views * 1000 order by cam.campaigns_daily_budget asc
Please inbox me if you are willing to work with me.
Waiting for your response.
Thanks
Kind Regards
Rehan828