実行したSQL
select
chr(60)||'table id='||chr(34)||'sort'||chr(34)||' name='||chr(34)||'sort'||chr(34)||chr(62)
|| chr(60)||'thead'||chr(62)||chr(60)||'tr'||chr(62)
|| chr(60)||'th title='||chr(34)||'ユーザID'||chr(34)||chr(62)||'ユーザ'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'初めて得点・コメントを入力した年'||chr(34)||chr(62)||'初'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'初めて得点・コメントを入力した日から、一番最近得点・コメントを入力した日の日数(得点・コメントは、発売前含む)'||chr(34)||chr(62)||'日数'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'現役=90日以内に得点・コメントを入力したユーザ、休止=180日以内に得点・コメントを入力したユーザ、引退=180日以上得点・コメントの入力ないユーザ(得点・コメントは、発売前含む)'||chr(34)||chr(62)||'状況'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'入力した得点の平均値'||chr(34)||chr(62)||'平均'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'入力した得点の標準偏差'||chr(34)||chr(62)||'偏差'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'時間(プレイ時間の登録がない場合は、ゲームのプレイ時間中央値を使用)'||chr(34)||chr(62)||'時間'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'入力した得点の数(null値除外)'||chr(34)||chr(62)||'数'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'得点を入力した日付の種類数(2010/01/01に100本登録、2010/01/02に1本登録した人は「2」となる)'||chr(34)||chr(62)||'登録日'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'ギブアップしたゲームの比率'||chr(34)||chr(62)||'Give'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'新作ゲーム(発売から180日以内に投稿)の比率'||chr(34)||chr(62)||'新作'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'新作ゲーム(発売から180日以内に投稿)の速報率(発売から30日以内に投稿した比率)'||chr(34)||chr(62)||'速報'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'90年代以前のゲームの比率'||chr(34)||chr(62)||'90s'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'00年代のゲームの比率'||chr(34)||chr(62)||'00s'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'10年代以降のゲームの比率'||chr(34)||chr(62)||'10s'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'メジャーゲーム(データ数100以上)の比率(同人を除く)'||chr(34)||chr(62)||'有名'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'マイナーゲーム(データ数30以下)の比率(同人を除く)'||chr(34)||chr(62)||'無名'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'コンシューマの比率'||chr(34)||chr(62)||'CS'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'同人の比率'||chr(34)||chr(62)||'同人'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'抜きゲーの比率'||chr(34)||chr(62)||'抜き'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'和姦ゲーの比率'||chr(34)||chr(62)||'和姦'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'陵辱ゲーの比率'||chr(34)||chr(62)||'陵辱'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'文字数による長文感想のスタイル(次の内、特に目立つスタイルに分類。無評=コメントなし/短評=500文字以内/中長文=2000文字以内/長文=2001文字以上)'||chr(34)||chr(62)||'長文'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'長文感想のネタバレ率'||chr(34)||chr(62)||'バレ'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'長文感想の参照回数の計(キャッシュ値の為、リアルタイムではない)'||chr(34)||chr(62)||'参照'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'長文感想の参照回数の最大(キャッシュ値の為、リアルタイムではない)'||chr(34)||chr(62)||'最大'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'長文感想の被投票数'||chr(34)||chr(62)||'投票'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'お気に入りユーザーへの投票数'||chr(34)||chr(62)||'人気'||chr(60)||'/th'||chr(62)
|| chr(60)||'th title='||chr(34)||'ピックアップ(最近3ヶ月の、被投票+被お気に入り投票数)'||chr(34)||chr(62)||'PU'||chr(60)||'/th'||chr(62)
|| chr(60)||'/tr'||chr(62)||chr(60)||'/thead'||chr(62)||'\n'||chr(60)||'tbody'||chr(62)
|| string_agg(
chr(60)||'tr'||chr(62)
|| chr(60)||'td onclick='||chr(34)||'link('||chr(39)||foo.uid||chr(39)||')'||chr(34)
|| ' class='||chr(34)||'uid'||chr(34)||chr(62)
|| foo.uid||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||date_part('year',foo.debut)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||date_part('day',foo.interval)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.active||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.avg,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.stddev,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.playtime||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.count||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.tourokubi||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.giveup*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.new_release*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.fast_review*100.0/(case when foo.new_release=0 then 100000 else foo.new_release end),0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.sellday_old*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.sellday_2000*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.sellday_new*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.major*100.0/(case when foo.count-foo.coterie<=0 then 100000 else foo.count-foo.coterie end),0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.minor*100.0/(case when foo.count-foo.coterie<=0 then 100000 else foo.count-foo.coterie end),0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round((foo.count-foo.pc)*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.coterie*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.okazu*100.0/foo.count,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.soft*100.0/(foo.soft+foo.hard),0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.hard*100.0/(foo.soft+foo.hard),0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)
|| case
when foo.count >= (foo.memo_500 + foo.memo_2000 + foo.memo_long) * 5 then '<!--1-->無評 '
when greatest(foo.memo_500*0.4, foo.memo_2000*0.7, foo.memo_long*1.0) = foo.memo_long*1.0 then '<!--4-->長文 '
when greatest(foo.memo_500*0.4, foo.memo_2000*0.7, foo.memo_long*1.0) = foo.memo_2000*0.7 then '<!--3-->中長文 '
when greatest(foo.memo_500*0.4, foo.memo_2000*0.7, foo.memo_long*1.0) = foo.memo_500*0.4 then '<!--2-->短評 '
end
|| chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||round(foo.netabare*100.0/case when foo.memo=0 then 100000 else foo.memo end,0)||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.display_total||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.display_max||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.touhyou||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.voter||chr(60)||'/td'||chr(62)
|| chr(60)||'td'||chr(62)||foo.pickup||chr(60)||'/td'||chr(62)
|| chr(60)||'/tr'||chr(62)
, '')
|| chr(60)||'/tbody'||chr(62)||chr(60)||'/table'||chr(62) as "</table>"
from
(
select ur.uid
, min(least(ur.play_tourokubi, ur.tourokubi, ur.before_tourokubi)) as debut
, max(greatest(ur.play_tourokubi, ur.tourokubi, ur.before_tourokubi)) - min(least(ur.play_tourokubi, ur.tourokubi, ur.before_tourokubi)) as interval
, case when max(greatest(ur.play_tourokubi, ur.tourokubi, ur.before_tourokubi)) >= current_date - '90 days'::interval then '<!--1-->現役'
when max(greatest(ur.play_tourokubi, ur.tourokubi, ur.before_tourokubi)) >= current_date - '180 days'::interval then '<!--2-->休止'
else '<!--3-->引退' end as active
, avg(ur.tokuten) as avg
, stddev(ur.tokuten) as stddev
, coalesce(sum(coalesce(ur.total_play_time, gl.total_play_time_median)), 0) as playtime
, count(case when ur.play='t' then 1 else null end) as count
, count(distinct to_char(ur.play_tourokubi,'yyyymmdd')) as tourokubi
, count(case when ur.giveup then 1 else null end) as giveup
, count( case when (ur.play_tourokubi::timestamp - gl.sellday::timestamp) <= '180 days'::interval then 1 else null end) as new_release
, count( case when (ur.play_tourokubi::timestamp - gl.sellday::timestamp) <= '30 days'::interval then 1 else null end) as fast_review
, count(case when gl.sellday<'2000-01-01'::timestamp then 1 else null end) as sellday_old
, count(case when gl.sellday between '2000-01-01'::timestamp and '2010-12-31'::timestamp then 1 else null end) as sellday_2000
, count(case when gl.sellday>'2010-12-31'::timestamp then 1 else null end) as sellday_new
, count(case when ttt.count>=100 and ttt.coterie is null then 1 else null end) as major
, count(case when ttt.count<=30 and ttt.coterie is null then 1 else null end) as minor
, count(case when gl.model='PC' then 1 else null end) as pc
, count(case when ttt.coterie=ttt.game_id then 1 else null end) as coterie
, count(case when gl.erogame then 1 else null end) as erogame
, count(case when gl.okazu then 1 else null end) as okazu
, count(case when gl.axis_of_soft_or_hard=-1 then 1 else null end) as hard
, count(case when gl.axis_of_soft_or_hard=1 then 1 else null end) as soft
, count(case when length(coalesce(ur.hitokoto,'')||coalesce(ur.memo,'')) = 0 then 1 else null end) as memo_zero
, count(case when length(coalesce(ur.hitokoto,'')||coalesce(ur.memo,'')) between 1 and 500 then 1 else null end) as memo_500
, count(case when length(coalesce(ur.hitokoto,'')||coalesce(ur.memo,'')) between 501 and 2000 then 1 else null end) as memo_2000
, count(case when length(coalesce(ur.hitokoto,'')||coalesce(ur.memo,'')) > 2000 then 1 else null end) as memo_long
, count(case when (ur.netabare='t' and ur.memo is not null) then 1 else null end) as netabare
, count(case when ur.memo is not null then 1 else null end) as memo
, sum(ur.display_unique_count) as display_total
, max(ur.display_unique_count) as display_max
, coalesce(max(ut.count_touhyou),0) as touhyou
, max(uu.count_user) as voter
, max(ut.count_touhyou_pickup) + max(uu.count_user_pickup) as pickup
from userreview as ur
, gamelist as gl
, toukei_temp_table as ttt
, userreview_toukei_table as urtt
, (select uid, count(voter_uid) as count_user
, sum(case when timestamp >= current_date - '3 months'::interval then 1 else 0 end) as count_user_pickup
from user_user group by uid having count(voter_uid)>=1) as uu
, ((select uid, count(voter_uid) as count_touhyou
, sum(case when timestamp >= current_date - '3 months'::interval then 1 else 0 end) as count_touhyou_pickup
from userreview_touhyou group by uid)
union
(select uid, 0 as count_touhyou, 0 as count_touhyou_pickup from myuserview where touhyou = 'f')) as ut
where ur.game = gl.id
and ur.game = ttt.game_id
and ur.uid = uu.uid
and ur.uid = urtt.uid
and urtt.tokuten_count >= 20
and urtt.hitokoto_count >= 10
and (urtt.tourokubi_max - urtt.tourokubi_min) >= '20 days'::interval
and urtt.tourokubi_min >= current_date - '2 years'::interval
and ur.uid = ut.uid
and ur.play = 't'
and ur.uid in (select uid from user_user group by uid having count(voter_uid)>=1)
group by ur.uid
) as foo