MySQL Forums
Forum List  »  General

Area "costs"
Posted by: Max Tsaren
Date: April 17, 2013 10:52AM

Sorry if I'm posting in the wrong section.
I am just looking for rectangular forms as of the moment so I am trying to get it working with vanilla mysql on phpmyadmin, I want to have a database where there are multiple areas that could potentially overlap each other, every area has a "cost" per square pixel, so you can get the cost at a certain point or measure the cost of an entire area while ignoring the parts that are being overlapped, you could also get the average of the total cost existing in the database.

I am wondering if one of you mysql vets could help me write such a query/database schema, I have already opened a topic on stackoverflow (http://stackoverflow.com/questions/16024462/advanced-mysql-area-costs?noredirect=1#comment22858074_16024462) and received the answer
select sum(c.cost)
from (select x.num as x, y.num as y, max(priority) as maxpriority
from numbers x cross join
numbers y join
costs c
on x.num between c.x and c.x + c.deltax and y.num between c.y + c.deltay
where x.value between PIXELX and PIXELX and DELTAX and
y.value between PIXELY and PIXELY and DELTAY
group by x.num, y.num
) xyp join
costs c
on xyp.x between c.x and c.x + c.deltax and xyp.y between c.y + c.deltay and
xyp.maxpriority = c.priority

which seems to be invalid and riddled with bugs, also no database schema was mentioned. I have put multiple days into trying to correct it and make it work but it keeps returning null.

Thanks in advance, I appreciate it.

Options: ReplyQuote


Subject
Written By
Posted
Area "costs"
April 17, 2013 10:52AM
April 18, 2013 08:21AM
April 18, 2013 10:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.