So what I'm trying to do at the moment is to select a dataset of values depending on another autocalculated value.(Sounds pretty complicated. It isn't I think and I'm not that much into english)
My SQL code looks like this:
SELECT ticket.ref_id AS id, COUNT( * ) AS reports, (COUNT(*)/post.views) AS
treshold,post.views AS views
FROM ticket, post
WHERE ticket.ref_id = post.id AND (reports/post.views)
GROUP BY ref_id
ORDER BY views,reports DESC
The problem is, when I try to use treshold or reports in the WHERE clause the query fails and says that there is no such value in 'field list'.
I know where the problem is, it's that MySQL seems not to allow the use of 'self defined' fields in the WHERE clause but i really need this and I dont know how to fix it.
Just using COUNT(*) doesn't work either because it doesn't know what to count.
Can anyone help me on this problem? I think it's totally basic SQL but I'm stuck on this at the moment.