i'm aware that this question has been asked multiple times and I have read those threads to get to where I am now, but those solutions don't seem to be working. I need to have a running total of my ExpectedAmount...

I have the following table:

```
+--------------+----------------+
| ExpectedDate | ExpectedAmount |
+--------------+----------------+
|            1 |        2485513 |
|            2 |         526032 |
|            3 |         342041 |
|            4 |         195807 |
|            5 |         380477 |
|            6 |         102233 |
|            7 |         539951 |
|            8 |         107145 |
|           10 |         165110 |
|           11 |          18795 |
|           12 |          27177 |
|           13 |          28232 |
|           14 |         154631 |
|           15 |        5566585 |
|           16 |         250814 |
|           17 |          90444 |
|           18 |         105424 |
|           19 |          62132 |
|           20 |        1799349 |
|           21 |         303131 |
|           22 |         459464 |
|           23 |         723488 |
|           24 |         676514 |
|           25 |       17311911 |
|           26 |        4876062 |
|           27 |        4844434 |
|           28 |        4039687 |
|           29 |        1418648 |
|           30 |        4366189 |
|           31 |        9028836 |
+--------------+----------------+

```

I have the following SQL:

```
SELECT a.ExpectedDate, a.ExpectedAmount, (SELECT SUM(b.ExpectedAmount)
                       FROM UnpaidManagement..Expected b
                       WHERE b.ExpectedDate <= a.ExpectedDate)
FROM   UnpaidManagement..Expected a

```

The result of the above SQL is this:

```
+--------------+----------------+--------------+
| ExpectedDate | ExpectedAmount | RunningTotal |
+--------------+----------------+--------------+
|            1 |        2485513 |      2485513 |
|            2 |         526032 |      9480889 |
|            3 |         342041 |     46275618 |
|            4 |         195807 |     59866450 |
|            5 |         380477 |     60246927 |
|            6 |         102233 |     60349160 |
|            7 |         539951 |     60889111 |
|            8 |         107145 |     60996256 |
|           10 |         165110 |      2650623 |
|           11 |          18795 |      2669418 |
|           12 |          27177 |      2696595 |
|           13 |          28232 |      2724827 |
|           14 |         154631 |      2879458 |
|           15 |        5566585 |      8446043 |
|           16 |         250814 |      8696857 |
|           17 |          90444 |      8787301 |
|           18 |         105424 |      8892725 |
|           19 |          62132 |      8954857 |
|           20 |        1799349 |     11280238 |
|           21 |         303131 |     11583369 |
|           22 |         459464 |     12042833 |
|           23 |         723488 |     12766321 |
|           24 |         676514 |     13442835 |
|           25 |       17311911 |     30754746 |
|           26 |        4876062 |     35630808 |
|           27 |        4844434 |     40475242 |
|           28 |        4039687 |     44514929 |
|           29 |        1418648 |     45933577 |
|           30 |        4366189 |     50641807 |
|           31 |        9028836 |     59670643 |
+--------------+----------------+--------------+

```

You can tell from the first few values already that the math is all off, but then at some points the math adds up?! I'm Too confused !! Could someone please point me to another solution or to where I have gone wrong with this?

I am using SQL Server 2008.