Well, I have a problem with creating a query to retrieve current inventory from a table which contains data in this way:
ID, Warehouse, Date, Stock
What I would like to get is the current stock information which is dated by last change of stock.
For example:
1, A, 2013-01-01, 1
1, A, 2013-01-02, 2
1, A, 2013-01-03, 4
1, A, 2013-01-05, 1
1, B, 2013-01-01, 1
1, B, 2013-01-02, 2
1, B, 2013-01-03, 4
2, B, 2013-01-01, 1
2, B, 2013-01-02, 2
2, B, 2013-01-03, 4
And as result I would like:
1, A, 2013-01-05, 1
1, B, 2013-01-03, 4
2, B, 2013-01-03, 4
For each ID last stock info for each warehouse.