1
我有這樣一個表(其實SuccessFlag更復雜)通過查詢組合計數組到單個表
AccountId SubaccountId SuccessFlag Count
10 1 true 5
10 1 false 1
10 2 true 6
10 2 false 2
21 1 true 7
21 1 false 3
21 2 true 8
21 2 false 4
,需要一個查詢,將形成這樣的表
AccountId SubaccountID Failed Total
10 1 1 6
10 2 2 8
21 1 3 10
21 2 4 12
不, 我需要總計算爲總和o f爲每個帳戶子帳戶對計數。 – loshurik
這正是我的例子所做的,因爲我在帳戶和子帳戶上使用GROUP BY。 – Dan
http://sqlfiddle.com/#!3/15fa8/1 – Dan