Vote count:
0
I have a table with many different companies, each with a number of orders ranging from only 1 to a possible n
I have used
ROW_NUMBER() OVER (PARTITION BY CompanyName ORDER BY OrderDate) AS Orders
This gives me a sample like below
Comp1 1
Comp2 1
Comp3 1
Comp3 2
Comp3 3
Comp3 4
Comp4 1
Comp4 2
Comp4 3
How do I go through the table and select the first and last record for each company? to end up with:
Comp1 1
Comp2 1
Comp3 1
Comp3 4
Comp4 1
Comp4 3
asked 1 min ago
first and last row_number
Aucun commentaire:
Enregistrer un commentaire