I have a mysql query that look likes this
select
s.id, sum(history.virality)
from
spreads s , (
select
( ( (sum(t.likes)) + ( sum(t.comments)) ) * ( 1 / ( 1 + s.created_at / 3600000 ) ) )as response
from
spreadstimeline t
where
t.spread_id = s.id
group by
DATE_FORMAT(t.created_at,'%Y-%m-%d %H')
) as history
group by
s.id
Mysql return an error "Unknown column 's.created_at' in 'field list'"
is there a possible way to get s to appear in the subquery, or should i start thinking of a different query.
Perhaps something along these lines: