FD、リニューアル、単体動作不可、パックものを除外
メインかサブで登録されている方のみで、4本以上縛り
select brand
, chr(60)||'ul style='||chr(34)||'list-style-type:none;padding:2px;margin:2px;'||chr(34)||chr(62)
|| chr(60)||'li style='||chr(34)||'display:inline;padding-right:4px;'||chr(34)||chr(62)
|| string_agg(
creater
|| '('||count||'本)'
, chr(60)||'/li'||chr(62)
|| chr(60)||'li style='||chr(34)||'display:inline;padding-right:4px;'||chr(34)||chr(62)
)
|| chr(60)||'/li'||chr(62)||chr(60)||'/ul'||chr(62) as creater
from (
select chr(60)||'span style='||chr(34)||'display:none;'||chr(34)||chr(62)
|| ttt.brandname||chr(60)||'/span'||chr(62)/*sort用*/
|| chr(60)||'a href='||chr(34)||'brand.php?brand='||ttt.brand_id||chr(34)||chr(62)
|| ttt.brandname
|| chr(60)||'/a'||chr(62) as brand
, chr(60)||'a href='||chr(34)||'creater.php?creater='||cl.id||chr(34)||chr(62)
|| cl.name
|| chr(60)||'/a'||chr(62) as creater
, count(*)
from toukei_temp_table as ttt
, createrlist as cl
, shokushu as ss
where ttt.game_id = ss.game
and cl.id = ss.creater
and ttt.model = 'PC'
and ss.shubetu = 5
and ss.shubetu_detail <= 2
and not ttt.game_id in (select game from attributegroupsboolean where attribute in (16,17,48,60))
/*FD、リニューアル、単体動作不可、パックものを除外*/
group by ttt.brandname, ttt.brand_id, cl.id, cl.name
having count(*) >= 4
order by count desc
) as foo
group by brand
order by brand