Hydrahon icon indicating copy to clipboard operation
Hydrahon copied to clipboard

SUM with IF

Open reklin7jc opened this issue 4 years ago • 0 comments

how would this consultation with the hydrahon be?

SUM(+1) as matches, SUM(IF((matches.playerblue = '.$idPlayer.' AND matches.rtb > matches.rtr) OR (matches.playerred = '.$idPlayer.' AND matches.rtr > matches.rtb), 1, 0)) as victories, SUM(IF((matches.playerblue = '.$idPlayer.' AND matches.rtb < matches.rtr) OR (matches.playerred = '.$idPlayer.' AND matches.rtr < matches.rtb), 1, 0)) as defeats, SUM(IF((matches.playerblue = '.$idPlayer.' AND matches.rtb = matches.rtr) OR (matches.playerred = '.$idPlayer.' AND matches.rtr = matches.rtb), 1, 0)) as drowns, SUM(IF(matches.playerblue = '.$idPlayer.', matches.rtb, 0) + IF(matches.playerred = '.$idPlayer.' , matches.rtr, 0)) as goalscored, SUM(IF(matches.playerblue = '.$idPlayer.', matches.rtr, 0) + IF(matches.playerred = '.$idPlayer.' , matches.rtb, 0)) as concededgoals, WHERE matches.playerblue = '.$idPlayer.' OR matches.playerred = '.$idPlayer.' LIMIT '.$games

reklin7jc avatar Jun 10 '20 22:06 reklin7jc