Q:

Calculating SQL ranking based on partial data

Given the following representative sample table;
Id    SupplierID    Amount     Time
-----------------------------------------------------------------
1     1             99.50      2016-02-17 13:19:21.4107347 +00:00
2     1             99.00      2016-02-17 15:00:40.1052771 +00:00
3     2             98.00      2016-02-17 15:07:07.6283091 +00:00
4     1             95.00      2016-02-17 16:40:08.4895886 +00:00
5     3             94.50      2016-02-17 16:40:18.7326269 +00:00
6     2             92.00      2016-02-17 16:40:44.0902749 +00:00
-----------------------------------------------------------------

I'd like to figure out the ranking for each supplier for every record in the table. So for each instance of [Time] I'd like to get a record for each supplier who has an entry in the table at or before that point in time, each indicating their rank at that given time. Rank is worked out over [Amount], lowest being first.
So for the example above, the complete recordset I'd hope for would be as follows;
Rank    SupplierID    Amount     Time
-----------------------------------------------------------------
1     1             99.50      2016-02-17 13:19:21.4107347 +00:00
1     1             99.00      2016-02-17 15:00:40.1052771 +00:00
1     2             98.00      2016-02-17 15:07:07.6283091 +00:00
2     1             98.00      2016-02-17 15:07:07.6283091 +00:00
1     1             95.00      2016-02-17 16:40:08.4895886 +00:00
2     2             95.00      2016-02-17 16:40:08.4895886 +00:00
1     3             94.50      2016-02-17 16:40:18.7326269 +00:00
2     1             94.50      2016-02-17 16:40:18.7326269 +00:00
3     2             94.50      2016-02-17 16:40:18.7326269 +00:00
1     2             92.00      2016-02-17 16:40:44.0902749 +00:00
2     3             92.00      2016-02-17 16:40:44.0902749 +00:00
3     1             92.00      2016-02-17 16:40:44.0902749 +00:00
-----------------------------------------------------------------

There can potentially be any number of [SupplierId]'s in the table, this example only shows three. 
I would include my query attempts so far but I've spent ~8 hours on this already and haven't come up with anything halfway decent.  I'd like to avoid dynamic SQL and I feel like there's a CTE or new V12 (SQL Server 2014 equivalent) expression which might do this neatly, but I haven't been able to find it. Or perhaps it's just a basic cross-join which I can't see. (I was kinda hoping that writing this out might spark some genius in me, but no joy).
I have done my due diligence and read about recursive CTE's, pivot tables using dynamic statements and windowing functions but I'm making no headway, so any help or pointers would be hugely appreciated.

A:

Boom. Managed to do it with a subquery. Hope it works for you!  
select rank() over(partition by t.time order by r.amount) as [Rank],
r.supplierid, t.amount, r.amount as supplieramount, t.[time] from (
    select yt1.id, max(yt2.id) as lastamount
    from #yourtable yt1
    inner join #yourtable yt2 on yt2.id <= yt1.id
    group by yt1.id, yt2.supplierid
    ) as d
inner join #yourtable t on t.id = d.id
inner join #yourtable r on r.id = d.lastamount
order by t.id, r.amount 

