By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
DealRelationID | RelType | ParentID | ChildID |
---|---|---|---|
1001 | 2 | 101 | 103 |
1002 | 2 | 102 | 105 |
1003 | 2 | 103 | 106 |
1004 | 2 | 104 | 107 |
1005 | 2 | 105 | 108 |
1006 | 2 | 106 | 110 |
1007 | 2 | 107 | 111 |
1008 | 2 | 111 | 112 |
DealID | ParentCNT | ChildCNT |
---|---|---|
106 | 0 | 0 |
107 | 0 | 0 |
108 | 0 | 0 |
109 | 0 | 0 |
ParentID | ChildCNT | ParentCNT |
---|---|---|
103 | 2 | 1 |
105 | 1 | 1 |
106 | 1 | 2 |
107 | 2 | 1 |
111 | 1 | 2 |
dealid | parent_cnt | child_cnt |
---|---|---|
101 | 0 | 3 |
102 | 0 | 2 |
103 | 1 | 2 |
104 | 0 | 3 |
105 | 1 | 1 |
106 | 2 | 1 |
107 | 1 | 2 |
108 | 2 | 0 |
110 | 3 | 0 |
111 | 2 | 1 |
112 | 3 | 0 |
Warning: Null value is eliminated by an aggregate or other SET operation.