<table class="demo">
<caption>Sample Data</caption>
<thead>
<tr>
<th>Acct</th>
<th>Type</th>
<th>Amount</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
<td> 101</td>
<td> H</td>
<td> 0</td>
<td> 111</td>
</tr>
<tr>
<td> 102</td>
<td> H</td>
<td> 0</td>
<td> 106</td>
</tr>
<tr>
<td> 103</td>
<td> R</td>
<td> 10</td>
<td> 106</td>
</tr>
<tr>
<td> 104</td>
<td> R</td>
<td> 20</td>
<td> 106</td>
</tr>
<tr>
<td> 105</td>
<td> R</td>
<td> 30</td>
<td> 106</td>
</tr>
<tr>
<td> 106</td>
<td> T</td>
<td> 0</td>
<td> 111</td>
</tr>
<tr>
<td> 107</td>
<td> H</td>
<td> 0</td>
<td> 110</td>
</tr>
<tr>
<td> 108</td>
<td> R</td>
<td> 15</td>
<td> 110</td>
</tr>
<tr>
<td> 109</td>
<td> R</td>
<td> 25</td>
<td> 110</td>
</tr>
<tr>
<td> 110</td>
<td> T</td>
<td> 0</td>
<td> 111</td>
</tr>
<tr>
<td> 111</td>
<td> T</td>
<td> 0</td>
<td> </td>
</tr>
<tbody>
</table>
Suppose I have data as shown in this table. I want sum to be calculated in total accounts by referring Total Into column. Also, total accounts have their own higher-level linking where they should be summed up. Can this be achieved in SQL server query? If not, then can someone guide me with SSRS expression to achieve this?
I tried to achieve this with multiple nested queries, partition by clause, etc. Then I switched to SSRS and tried a few expressions. But now I'm kind of stuck