I have a result set of 500 rows, but this are for 100 invoice.
I need only the top 10 of the last invoices.
I found something like similar: How to select top 10 records from each category
Sample data:
InvNr | DetailLine
111 | 1
111 | 2
112 | 1
112 | 2
112 | 3
113 | 1
113 | 2
114 | 1
115 | 1
... | ...
What I hope to get is for example:
SELECT DISTINCT TOP 2 InvNr, DetailLine FROM tbl_Invoice
With this result:
InvNr | DetailLine
111 | 1
111 | 2
112 | 1
112 | 2
112 | 3
Update:
So I need the last 10 (or first 2 in the example above) invoices they have created, but each invoice can have "x" amount of detail lines and I want all their detail lines (of these last 10) in the results.
Best Answer