What I’m trying to do is have it where I get the occurances on an id in the table, and then based upon the amount of occurances, divide the value of another column by that value. Here’s the query to better illustrate what I’m trying to do.
SELECT t.t_id, count(DISTINCT tm.tm_id) AS occurances, t.value/occurances AS newValue
FROM table t
INNER JOIN table_map tm ON t.t_id = tm.tm_id
GROUP BY tm.tm_id
HAVING occurances > 1
As those that are familiar with SQl, this wont’ work. However I’m at a loss as to how to get it to perform what I need, or if it’s possible. I tried doing a select within a select, but couldn’t figure out how to get it to perform the operations that I need.
The sql is being performed on a MySQL 5 DB
Maybe you meant something like this: