List all articles with their amounts at a certain date+time
I you don't care about the time in the result it's pretty easy:

select article_id, sum(amount)
from stock_history 
where amount_at &lt;= '2016-03-01 00:00:00'
group by article_id


If you want time, you need to determine which time you should present. If you want the same time as in the where clause you can just add it since it is a constant:

select article_id, '2016-03-01 00:00:00', sum(amount)
from stock_history 
where amount_at &lt;= '2016-03-01 00:00:00'
group by article_id


Assuming it is the last time before this time you can map all times to this time with a derived table and use that:

select a.article_id, b.amount_at, sum(a.amount)
from stock_history a
join ( select article_id, max(amount_at) as amount_at 
       from stock_history 
       where amount_at &lt;= '2016-03-01 00:00:00'
       group by article_id
) as b
    on a.rticle_id = b.article_id
   and a.amount_at &lt;= b.amount_at
group by a.article_id, b.amount_at;