SELECT os, browser, sum(page_views) FROM test.ga_tb2 GROUP BY GROUPING SETS ((os, browser), os, ()) -- ここ、また微妙に変えた HAVING sum(page_views) > 20 ORDER BY os, browser; os | browser | sum -----------+-------------------+------- Android | Android Browser | 254 <- OSとブラウザ別 Android | Chrome | 472 Android | Firefox | 232 Android | Opera | 73 Android | | 1036 <- OS別の小計 iOS | Chrome | 41 iOS | Safari | 625 iOS | Safari (in-app) | 37 iOS | | 703 <- OS別の小計 Linux | Chrome | 301 Linux | Firefox | 692 Linux | | 1008 <- OS別の小計 Macintosh | Chrome | 1392 Macintosh | Firefox | 409 Macintosh | Safari | 897 Macintosh | | 2730 <- OS別の小計 Windows | Chrome | 15377 Windows | Firefox | 6492 Windows | Internet Explorer | 12264 Windows | Iron | 84 Windows | Opera | 359 Windows | | 34628 <- OS別の小計 | | 40145 <- 総計行 (23 rows) 注:HAVING句で集計値20より大きい行に絞り込んでいるため、 OS別の小計は、出ていない「その他」のブラウザを含む値です。 例えば Linux 小計 1008 > (Linux-Chorome 301 + Linux-Firefox 692)