我有以下查询:
this
哪个正确地将3行插入到了mean_subs表中。但是,当我删除WHERE条件(INSERT INTO median_subs
SELECT dd.subscriber_id,AVG(dd.subscribers) as median_val
FROM (
SELECT d.subscriber_id,d.subscribers, @rownum:=@rownum+1 as `row_number`, @total_rows:=@rownum
FROM historic d, (SELECT @rownum:=0) r
WHERE d.subscribers is NOT NULL
AND d.subscriber_id IN (1,2,3)
GROUP BY d.subscriber_id
ORDER BY d.subscribers
) as dd
WHERE dd.row_number IN ( FLOOR((@total_rows+1)/2), FLOOR((@total_rows+2)/2) )
GROUP BY dd.subscriber_id ORDER BY NULL
)时,查询仅将一行插入表中。表AND d.subscriber_id IN (1,2,3)
具有以下格式:
historic