mysql - Finding a unique value from 2 columns and then a ratio of those values -
i have table columns id, player1, , player2. id's player can in either of 2 columns. need find unique id's in column player1 , column player2 combined. need find amount of times each player appears in each column. want order ratio of column player1 / column player2.
for instance, have following values in table.
1 103 101
2 103 111
3 232 103
4 223 111
my query return..
player 223: 1/0
player 232: 1/0
player 103: 2/1
player 101: 0/1
player 111: 0/2
i know unique ids can this
select (select group_concat(distinct player1) table) player1, (select group_concat(distinct player2) table) player2
and know order can this
order player1 / player2 desc
i'm having hard time figuring out once unique id , try ratios outputed , sorted
try this
select player1,player2, concat('player',if( (select count(dt.player1) table dt mt.player1 = dt.player1) > 0, player1,player2),':', (select count(dt.player1) table dt mt.player1 = dt.player1), ' / ', (select count(dt.player2) table dt mt.player2 = dt.player2) ) table mt player1 != player2 group palyer1,player2 order (player1/if(player2 not null , player2 != 0,player2,1) desc
i hope helps you
Comments
Post a Comment