select pc.*
,(select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1) a_dt
,datediff(NOW(), (select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1)) as d_count
,(select max_gp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as max_gp
,(select tp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as tp
,(select name_r from #__rad_swgoh_char cc where cc.id=pc.char_id ) as name_r
,(select count(*) from #__rad_swgoh_playerchar_mod m where m.char_id=pc.char_id and m.player_id=pc.player_id and m.star=6) as mod6
from #__rad_swgoh_playerchar_tb pc where player_id in
(select id from #__rad_swgoh where char_id in (5,64,11,20,24,154,57,10,99,23,1,102,15,108,138,105,13,36,121,135,16,92,173,104,107,142,84,160,153,1077634,43,86,148,129,126,158,69,5,11,20,24,154,57,159,10,65,99,23,1,102,15,108,138,105,62,13,161,36,121,135,16,92,173,104,107,142,84,160,153,1077634,43,86,148,129,158) and state=1 and is_ourgild=1 )
order by pgp_proc descselect pc.*
,(select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1) a_dt
,datediff(NOW(), (select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1)) as d_count
,(select max_gp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as max_gp
,(select tp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as tp
,(select name_r from #__rad_swgoh_char cc where cc.id=pc.char_id ) as name_r
,(select count(*) from #__rad_swgoh_playerchar_mod m where m.char_id=pc.char_id and m.player_id=pc.player_id and m.star=6) as mod6
from #__rad_swgoh_playerchar_tb pc where player_id in
(select id from #__rad_swgoh where char_id in (5,14,94,11,123,20,24,57,10,65,31,1,21,15,108,138,98,13,146,17,74,121,135,16,92,93,173,104,164,107,59,142,84,160,120,113,1077634,43,86,157,69,115) and state=1 and is_ourgild=1 )
order by pgp_proc descselect pc.*
,(select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1) a_dt
,datediff(NOW(), (select dt from #__rad_swgoh_playerchar_history h where h.char_id=pc.char_id and h.player_id=pc.player_id order by dt desc limit 1)) as d_count
,(select max_gp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as max_gp
,(select tp from #__rad_swgoh_char cc where cc.id=pc.char_id ) as tp
,(select name_r from #__rad_swgoh_char cc where cc.id=pc.char_id ) as name_r
,(select count(*) from #__rad_swgoh_playerchar_mod m where m.char_id=pc.char_id and m.player_id=pc.player_id and m.star=6) as mod6
from #__rad_swgoh_playerchar_tb pc where player_id in
(select id from #__rad_swgoh where char_id in (5,11,20,24,154,57,159,10,65,99,23,1,102,15,108,138,105,62,13,161,36,121,135,16,92,173,104,107,142,84,160,153,1077634,43,86,148,129,158) and state=1 and is_ourgild=1 )
order by pgp_proc desc