select number0_cnt,number1_cnt,number2_cnt,number3_cnt,count(*) as cnt from ( select n_round ,0 + case when number1 = 0 then 1 else 0 end + case when number2 = 0 then 1 else 0 end + case when number3 = 0 then 1 else 0 end + case when number4 = 0 then 1 else 0 end + case when number5 = 0 then 1 else 0 end + case when number6 = 0 then 1 else 0 end + case when number7 = 0 then 1 else 0 end + case when number8 = 0 then 1 else 0 end + case when number9 = 0 then 1 else 0 end + case when number10 = 0 then 1 else 0 end + case when number11 = 0 then 1 else 0 end + case when number12 = 0 then 1 else 0 end + case when number13 = 0 then 1 else 0 end as number0_cnt ,0 + case when number1 = 1 then 1 else 0 end + case when number2 = 1 then 1 else 0 end + case when number3 = 1 then 1 else 0 end + case when number4 = 1 then 1 else 0 end + case when number5 = 1 then 1 else 0 end + case when number6 = 1 then 1 else 0 end + case when number7 = 1 then 1 else 0 end + case when number8 = 1 then 1 else 0 end + case when number9 = 1 then 1 else 0 end + case when number10 = 1 then 1 else 0 end + case when number11 = 1 then 1 else 0 end + case when number12 = 1 then 1 else 0 end + case when number13 = 1 then 1 else 0 end as number1_cnt ,0 + case when number1 = 2 then 1 else 0 end + case when number2 = 2 then 1 else 0 end + case when number3 = 2 then 1 else 0 end + case when number4 = 2 then 1 else 0 end + case when number5 = 2 then 1 else 0 end + case when number6 = 2 then 1 else 0 end + case when number7 = 2 then 1 else 0 end + case when number8 = 2 then 1 else 0 end + case when number9 = 2 then 1 else 0 end + case when number10 = 2 then 1 else 0 end + case when number11 = 2 then 1 else 0 end + case when number12 = 2 then 1 else 0 end + case when number13 = 2 then 1 else 0 end as number2_cnt ,0 + case when number1 = 3 then 1 else 0 end + case when number2 = 3 then 1 else 0 end + case when number3 = 3 then 1 else 0 end + case when number4 = 3 then 1 else 0 end + case when number5 = 3 then 1 else 0 end + case when number6 = 3 then 1 else 0 end + case when number7 = 3 then 1 else 0 end + case when number8 = 3 then 1 else 0 end + case when number9 = 3 then 1 else 0 end + case when number10 = 3 then 1 else 0 end + case when number11 = 3 then 1 else 0 end + case when number12 = 3 then 1 else 0 end + case when number13 = 3 then 1 else 0 end as number3_cnt from TotoGoal_Daily ) a group by number0_cnt,number1_cnt,number2_cnt,number3_cnt order by cnt desc
summaryDailyPattern() error occured.