I have this query:
select article_number, date, company, size, price
from price
order by article_number, company, date
that produces these results:
('50240-20', '2016-03-08 13:06:12.872955', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:13:55.311955', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:47:13.737155', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:51:32.677155', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:06:12.872955', 'Bio', '20', '423,20')
('50240-20', '2016-03-08 13:13:55.311955', 'Bio', '20', '423,20')
('50240-20', '2016-03-08 13:47:13.737155', 'Bio', '20', '423,20')
('50240-20', '2016-03-08 13:51:32.677155', 'Bio', '20', '423,20') ...
I want to limit the results for each article_number
and company
selection so that it only show 2 results with 2 last different dates. So the result should look like:
('50240-20', '2016-03-08 13:47:13.737155', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:51:32.677155', '2B', '20', '645,75')
('50240-20', '2016-03-08 13:47:13.737155', 'Bio', '20', '423,20')
('50240-20', '2016-03-08 13:51:32.677155', 'Bio', '20', '423,20') ...
Can anyone help me how to do this? A simple limit 2 at the end will only give out 2 results at all and not for each "group"
THX!