mysql> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 0 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 0 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 0 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 1 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 0 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 0 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 0 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 1 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 0 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 0 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 1 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 0 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 0 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 1 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 1 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 0 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 1 and cd4 = 0 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 0 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 0 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 1 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 1 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 0 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 1 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 1 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 0 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 0 and cd3 = 1 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 1 and cd4 = 1 and cd5 = 0 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 1 and cd4 = 0 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 0 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 0 and cd3 = 1 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 0 and cd2 = 1 and cd3 = 1 and cd4 = 1 and cd5 = 1 union -> SELECT count(*) as count, sum(vp) as vp_total, sum(hp) as hp_total from hands where cd1 = 1 and cd2 = 1 and cd3 = 1 and cd4 = 1 and cd5 = 1; +---------+------------------+----------+ | count | vp_total | hp_total | +---------+------------------+----------+ | 1712304 | 33894283.5520849 | 364228 | | 194580 | 3951801.66152954 | 35730 | | 194580 | 3953112.74213982 | 33877 | | 194580 | 3952714.36095715 | 34705 | | 194580 | 3952319.72564888 | 35804 | | 194580 | 3951929.28067398 | 37320 | | 17296 | 331488.688423157 | 2592 | | 17296 | 331469.418542862 | 2592 | | 17296 | 331450.180427551 | 2592 | | 17296 | 331430.974077225 | 2592 | | 17296 | 331532.783657074 | 2772 | | 17296 | 331513.545544624 | 2772 | | 17296 | 331494.339183807 | 2772 | | 17296 | 331498.053476334 | 3043 | | 17296 | 331478.847108841 | 3043 | | 17296 | 331463.831225395 | 3460 | | 1128 | 18795.6588506699 | 252 | | 1128 | 18795.2144079208 | 252 | | 1128 | 18794.7699651718 | 252 | | 1128 | 18794.8017101288 | 252 | | 1128 | 18794.3572673798 | 252 | | 1128 | 18793.9445695877 | 252 | | 1128 | 18796.6112232208 | 343 | | 1128 | 18796.1667804718 | 343 | | 1128 | 18795.7540826797 | 343 | | 1128 | 18795.8175697327 | 489 | | 48 | 639.341274261475 | 91 | | 48 | 639.373019218445 | 146 | | 1 | 9.81746006011963 | 50 | +---------+------------------+----------+ 29 rows in set (26.57 sec)