| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
編集の要約なし
==[[DB2 GROUP BY 拡張]]==[[DB2]] | {{category [[Category:SQL}}]]
===ROLLUP[[R]]OLLUP===
*グループごとのサマリーを作成
SELECT t.name AS tour_name,
c.name AS county_name,
COUNT(*) AS falls_count
FROM F[[R]]OM upfall u INNER INNE[[R]] JOIN trip t
ON u.id = t.stop
INNER INNE[[R]] JOIN county c
ON u.county_id = c.id
GROUP G[[R]]OUP BY ROLLUP[[R]]OLLUP(t.name, c.name);
TOUR_NAME TOU[[R]]_NAME COUNTY_NAME FALLS_COUNT
---------- ----------- ----------------------
M-28 Alger 3
c.name county_name,
COUNT(*) AS falls_count
FROM F[[R]]OM upfall u INNER INNE[[R]] JOIN trip t
ON u.id = t.stop
INNER INNE[[R]] JOIN county c
ON u.county_id = c.id
WHERE WHE[[R]]E t.name = 'Munising' GROUP G[[R]]OUP BY CUBE(t.name, c.name);
TOUR_NAME TOU[[R]]_NAME COUNTY_NAME FALLS_COUNT
---------- ----------- ----------------------
6
Munising Alger 6
===GROUP G[[R]]OUP BY で有用な関数=======GROUPINGG[[R]]OUPING( column )====*CUBE, ROLLUPの結果が [[R]]OLLUPの結果が NULL の場合、1を返す、そうでない場合、0を返す

案内メニュー