我有一个看起来像这样的
的mysql查询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在“字段列表”中返回错误“未知列's.created_at'”
是否有可能让s出现在子查询中,或者我应该开始考虑不同的查询。
答案 0 :(得分:1)
也许是这些方面的事情:
select
s.id, sum_virality, ( ( (sum_likes) + ( sum_comments) ) * ( 1 / ( 1 + s.created_at / 3600000 ) ) )as response
from spreads s
inner join (select t.spread_id, DATE_FORMAT(t.created_at,'%Y-%m-%d %H') created_date, sum(t.virality) sum_virality, sum(t.likes) sum_likes, sum(t.comments) sum_comments
from spreadstimeline t
where t.spread_id = s.id
group by created_date) as history
group by
s.id