SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am looking for a way to select only the lines with the earliest date per order-operation line. So in this case let's say that the database is called orderlines and it looks like :
I am looking for a way to select the earliest date per Orderopr line so per 123-10, 123-20, 124-10 etc. For some reaso I do not succeed in selecting only the earliest dates....
Check one on typical solutions:
select [order], operation, Orderopr, [date]
from
(
select *, row_number() over (partition by [order], operation order by [date]) n
from orderlines
) o
where n = 1
order by [order], operation