プレイ時間が長いゲームが中央値高めになる傾向があるので その傾向を最小二乗法という方法で方程式化、それを超えるゲームを表示してます。(dmm遊び放題配信のみ)
SELECT
'<a href="https://dlsoft.dmm.co.jp/detail/' || dmm || '/" target="_blank">' || '<img src="http://pics.dmm.co.jp/digital/pcgame/' || dmm || '/' || dmm || 'ps.jpg"></a>'
as 画像
,total_play_time_median プレイ時間,round(a*total_play_time_median+b,1) as 期待値, t.median as 実際の中央値,t.count as データ数,round(ur.o) as おかず指数
,case when t.game_id in(select game from ooparts_game) then '有り' else null end as ooparts
,
'<A href="http://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/game.php?game='||t.game_id||'">'||t.gamename||'</A>'
ゲーム名
,'<A href="http://erogamescape.dyndns.org/~ap2/ero/toukei_kaiseki/brand.php?brand='||t.brand_id||'">'||t.brandname||'</A>' ブランド名
from gamelist g, toukei_temp_table t,
( SELECT xy/xx a,y-xy/xx*x b from
(SELECT sum(total_play_time_median*count)/sum(count*1.0) x,sum(t.median*count) /sum(count*1.0) y
,sum((total_play_time_median-x)*(t.median-y)*count) xy
,sum((total_play_time_median-x)*(total_play_time_median-x)*count) xx
from gamelist g, toukei_temp_table t,
(SELECT sum(total_play_time_median*count)/sum(count*1.0) x,sum(t.median*count) /sum(count*1.0) y
FROM gamelist g, toukei_temp_table t
where g.id= t.game_id and
total_play_time_median is not null
and dmm_subsc is not null
)xy
where g.id= t.game_id and
total_play_time_median is not null
and dmm_subsc is not null
)a)ab
,(SELECT game,avg(
case when okazu_tokuten in (4,3,2,1)then okazu_tokuten*20+20
when okazu_tokuten in(-1,-2) then okazu_tokuten*20+40
else null end) as o
from
userreview group by game)ur
where t.median>=a*total_play_time_median+b
and dmm_subsc is not null and g.id=t.game_id
and ur.game=g.id
order by (t.median-(a*total_play_time_median+b))
desc,t.sellday desc